I followed the docs to create a mysql fly.io app ( link and it works fine, I can proxy it on my localhost and connect to it, see the data, etc.
I don’t really know, or seems like I don’t understand, how to connect to the database from my java spring boot app. Here’s my sql app fly.toml:
app = "bikes4all-mysql" primary_region = "otp" kill_signal = "SIGINT" kill_timeout = 5 [processes] app = """--datadir /data/mysql \ --default-authentication-plugin mysql_native_password \ --performance-schema=OFF \ --innodb-buffer-pool-size 64M""" [mounts] source="mysqldata" destination="/data" [env] MYSQL_DATABASE = "inginerie_software" MYSQL_USER = "db_user" [build] image = "mysql:8.0.32"
and from what I seen in the docs, I have to access it something like
I tried it like this in my springboot application.properties:
spring.datasource.url=jdbc:mysql://https://bikes4all-mysql.internal:3306 spring.datasource.username=db_user spring.datasource.password=somepassword spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
but I get erros like:
WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
As I said, if I instead use the proxy (i proxy it on port
13306) in my application.properties like this:
spring.datasource.username=db_user spring.datasource.password=password spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
everything works fine and it connects to the database
I tried again, a clean start and a new fly app to deploy the sql, just to be sure there is nothing else that gets in the way.
I followed the exact steps in the docs, and this is how my sql fly app looks:
app = "mysql-bikes4all" kill_signal = "SIGINT" kill_timeout = 5 primary_region = "otp" [processes] app = """--datadir /data/mysql \ --default-authentication-plugin mysql_native_password \ --performance-schema=OFF \ --innodb-buffer-pool-size 64M""" [mounts] source="mysqldata" destination="/data" [env] MYSQL_DATABASE = "inginerie_software" MYSQL_USER = "non_root_user" [build] image = "mysql:8.0.32"
fly deploy, then
fly scale memory 2048 and again
fly deploy and it gets deployed. ( I do
fly deploy before the
fly scale memory 2048 because if no deployment before, i was getting this error:
failed to grab app config from existing machines, error: could not create a fly.toml from any machines :-( No machines configured for this app
So, after I ran these commands, if I go and now try to proxy it on my localhost, it doesn’t work.
flyctl proxy 13306:3306 -a mysql-bikes4all results into this output:
mysql-bikes4all.internal: host was not found in DNS
Any ideas? (This edit is for the purpose of recreating this scenario)
I cloned the machine the sql was running on ( I had only one, and it was suggested to clone the current one to make them 2 ) so now I can proxy it on my localhost again, and I can connect on my command prompt or spring boot to the database ( if it’s proxied on localhost). But still can’t connect to it remotely, let’s say
mysql -hmysql-bikes4all.internal in command line or
spring.datasource.url=jdbc:mysql://mysql-bikes4all.internal/inginerie_software in my spring boot application.properties.
this is the output of
ERROR 2005 (HY000): Unknown MySQL server host 'mysql-bikes4all.internal' (11001)