Closed arnaudveron closed 6 years ago
I suggest the following to fix the issue : https://gist.github.com/arnaudveron/4c0ac6d16fc364dfa54f48f87f333743
Hi @arnaudveron
Thanks for the issue and gist! I'm definitely open for a PR if you have time. It would be good not to change the main set of variables used as it will affect existing users. You could actually parse the MySQL hostname and port from the DATABASE URL and if the port is not the default port, add the -port option to the myql command. That would be a transparent change for everyone 😄
Hi @jjethwa
I do not understand why you say that I change the whole set of variables. In the gist, MYSQL_CNX_STRING, MYSQL_SERVER_NODE, MYSQL_SERVER_PORT are all evaluated from DATABASE_URL, which is exposed in the Dockerfile, so I do not see any change for the existing users.
I sincerely believe that the change in the gist is fully transparent for everyone :
Case 1 => DATABASE_URL="jdbc:mysql://localhost/rundeckdev?autoReconnect=true" MYSQL_CNX_STRING=localhost MYSQL_SERVER_NODE=localhost MYSQL_SERVER_PORT=3306 #default for mysql mysql --host=localhost --port=3306
Case 2 => DATABASE_URL="jdbc:mysql://localhost:12345/rundeckdev?autoReconnect=true" MYSQL_CNX_STRING=localhost:12345 MYSQL_SERVER_NODE=localhost MYSQL_SERVER_PORT=12345 mysql --host=localhost --port=12345
Please tell me if I missed something.
Hi @arnaudveron
Sorry about that! I must have missed the first few changes, so I did not see the assignments. Upon checking again, I see that getting everything from DATABASE_URL. Please send a PR when you have a moment. Really appreciate it :smile:
Using external mysql instance on non default tcp port makes the sql connection fail.
Using the connection string below : DATABASE_URL="jdbc:mysql://localhost:32220/rundeckdev?autoReconnect=true"
In the logs : =>NO_LOCAL_MYSQL set to true. Skipping local MySQL setup =>Initializing remote MySQL setup ERROR 2005 (HY000): Unknown MySQL server host 'localhost:32220' (-2)
Due to the command below : mysql --host=$(echo ${DATABASE_URL} | grep -oP "(?<=jdbc:mysql:\/\/)(.*)(?=\/)") being evaluated as : mysql --host=localhost:32220