glen

glen

Is there a way to change the default database instance from Postgres to Mariadb or Mysql for ecto? I am aware of the option to use the database flag, but since I have years more experience with mysql, I’d love to make it the default.

Showing Posts 1 to 9

John-Goff

John-Goff

I do not believe that there is any kind of config file or anything that you could set to make your choice of database the default. I think that generally the generators are only used once when creating a project, so I’m not sure that adding such an option would be all that beneficial. If you are in fact creating new Phoenix projects on the regular you could always create a bash script which passes the flags you would like.

wmnnd

wmnnd

Take a look at the docs for mix phx.new: mix phx.new — Phoenix v1.8.8

You can simply specify the --database mysql option when creating a new Phoenix project.

kokolegorille

kokolegorille

You can always make some kind of shell alias if You really want to avoid typing –database mysql.

But You cannot change default value of phx.new

OvermindDL1

OvermindDL1

You could, however, fork it and make your own version to change the default and install your fork locally. ^.^

Seems like it would be a pretty minimal patchset to keep in sync. Maybe even PR it looking in a config in $XDG_CONFIG_HOME somewhere for what default config options for it to set (don’t forget to log to user that it found a config file at a given location and is using it for defaults so it’s not silently surprising).

kokolegorille

kokolegorille

Yes, forking is a possibility :slight_smile:

glen

glen OP

Yes, but I think I’m too much of an Elixir virgin and not ready to fork…

I am at the stage where I am running several tutorials and wondering whether I am better off biting the bullet and using Postgres for now or figure out how to modify the scripts that call mix setup or phx.new to make it use MySQL.

It’s mainly the Postgres shell that makes me slow and unhappy. Maybe I’ll try a gui for Postgres and see if that works around the issue.

Thanks for your feedback, all.

kokolegorille

kokolegorille

I would recommend to use postgresql if You want to follow tutorials, because there are some differences with mysql. Almost all tutorials I saw use it.

like ordering, or search case sensitivity, or extensions (citext, postgis etc).

I have often used mysql with Rails, but once I had to use windows functions. I don’t know if it is supported by mysql now, but 5 years ago it was not.

It’s always possible to switch later.

John-Goff

John-Goff

I would recommend using postgres, I started with MySQL and while it worked fine, there was a subset of ecto features that I wanted to use which required using postgres. Though switching from mysql to postgres was relatively painless all things considered, so if you do decide to go with one and then change your mind it should be doable. But yeah I wouldn’t bother modifying the script for phx.new, just use the --database flag or like I said earlier, wrap it in a bash script.

glen

glen OP

In case it’s of interest, in the last 2 or 3 years windowed functions and other features like virtual columns have received significant upgrades on Mariadb and MySQL, with little functionality missing compared to MSSQL for example. Although Mariadb is usually ahead of the curve.

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

gus
Happy Friday, all! :slight_smile: Our October meetup is coming up next week - Wednesday, October 14th at 19h CET via Zoom! This month we...
New
CodeSync
We have 4 in-person tickets to Code BEAM Europe 2026 (21-22 October, PHIL Haarlem) to give away: 1 diversity ticket (sponsored by AppSi...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews