Noobies Question - mysql vol not being populated

Hi Fly.io Community!

I am new to fly.io and exploring it as a service for our app’s hosting.

It is Laravel based, and have an app and machine working correctly for our product.

I’ve also attached a volume have that storage being persistent across machine restarts.

I’ve also setup another machine/app for the database using this guide - Use a MySQL Database · Fly Docs and also successfully attached a volume.

It can connect to it successfully using the .internal app name and I am able to run artisan commands from the machine hosting the source code to populate the DB but upon restarting the machine - the database is wiped.

here is what my toml file looks like

~~
app = “testapp”
kill_signal = “SIGINT”
kill_timeout = 5

[mounts]
source=“mysqldata”
destination=“/data/mysql”

[env]
MYSQL_DATABASE = “testdb”
MYSQL_USER = “non_root_user”

[build]
image = “mysql:5.7”

[experimental]
cmd = [
“–default-authentication-plugin”,
“mysql_native_password”,
“–datadir”,
“/data/mysql”
]
~~

I cant see any mysql files in /data/mysql being populated in this mounted vol.

Can someone please give me a pointer on what I am doing wrong?

Thanks!

Hey there!

It looks like our docs for running mysql need updating since we made our “apps v2” the default. That changed the fly.toml file a bit.

What you’re seeing is the [experimental] settings get ignored, and thus the --datadir flag isn’t used. (Also the destination section in [mount] needs a tweak)

We’re working on the docs now (thanks for the nudge!)

For mysql 5.7, use this for your fly.toml:

app = "testapp"
kill_signal = "SIGINT"
kill_timeout = 5

# Set this to whatever region you're
# deploying into
primary_region = "bos"

[processes]
app = "--datadir /data/mysql"

[mounts]
  source="mysqldata"
  destination="/data"

[env]
  MYSQL_DATABASE = "testdb"
  MYSQL_USER = "non_root_user"

[experimental]
  auto_rollback = true

[build]
  image = "mysql:5.7"

Things to note:

  1. Added primary_region
  2. [processes] section now contains the cmd flags in it as a string
    • Removed the [experimental] section completely
    • Only need the --datadir flag for mysql 5.7 (the other flag is more for mysql 8)
  3. Mount destination is /data, not /data/mysql, but the --datadir flag DOES use /data/mysql

Let me know how that goes and if you get any more errors/issues!

1 Like

that worked great thank you!

just curious, what adjustments would need to be made for mysql 8?

i scaled the vm to add more ram and adjusted the [process] cmd line as follows but it see a connection refused

app = “–default-authentication-plugin mysql_native_password --datadir /data/mysql”

There’s an issue with the latest MySQL release (8.0.33), but if you try

[build]
  image = "mysql:8.0.32"

then it should work. We’re just updating the docs now as well (for V2 Apps), so thanks for bringing this up!

You can also potentially reduce MySQL 8’s memory usage by adding these additional flags to the app process:

[processes]
app = "--default-authentication-plugin mysql_native_password --datadir /data/mysql --performance-schema=OFF --innodb-buffer-pool-size 64M"

That worked wonderfully thank you!

Ah sorry, I forgot to mention that. Here’s the GH issue related to that: mysql 8.0.33 fails on Fly.io but works with 8.0.32 · Issue #967 · docker-library/mysql · GitHub

Hopefully it gets resolved OR 8.0.34 doesn’t have that bug.

1 Like

Thank you team :slight_smile:

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.