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
MYSQL_DATABASE = “testdb”
MYSQL_USER = “non_root_user”
image = “mysql:5.7”
cmd = [
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?
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
app = "testapp"
kill_signal = "SIGINT"
kill_timeout = 5
# Set this to whatever region you're
# deploying into
primary_region = "bos"
app = "--datadir /data/mysql"
MYSQL_DATABASE = "testdb"
MYSQL_USER = "non_root_user"
auto_rollback = true
image = "mysql:5.7"
Things to note:
[processes] section now contains the
cmd flags in it as a string
[experimental] section completely
Only need the
--datadir flag for mysql 5.7 (the other flag is more for mysql 8)
Mount destination is
/data/mysql, but the
Let me know how that goes and if you get any more errors/issues!
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”
April 25, 2023, 10:02pm
There’s an issue with the latest MySQL release (8.0.33), but if you try
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 = "--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.
May 3, 2023, 2:01am
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.