dokku/dokku-mysql

Using dash in database names in older MySQL versions

cu12 opened this issue · 3 comments

cu12 commented

I need to use MySQL 5.6.20 for various reasons and the following happens when I create the container:

# export MYSQL_IMAGE_VERSION='5.6.20'; dokku mysql:create slot-2-backend
-----> Starting container
       Waiting for container to be ready
=====> MySQL container created: slot-2-backend
       DSN: mysql://mysql:3317e6732f3f67dd@dokku-mysql-slot-2-backend:3306/slot-2-backend
root@ip-172-31-31-212:/var/log/upstart# dokku mysql:connect slot-2-backend
Warning: Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: YES)

When I create a container without the dash, I can access it without any problem.

The reason is that text before dash is eaten, as you could see below:

mysql> create database slot-2-backend;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-2-backend' at line 1

Using the backticks, it works fine:

mysql> create database `slot-2-backend`;
Query OK, 1 row affected (0.00 sec)

Kinda edge-case, although since the fix I'll propose is super simple and doesn't break anything, I thought it would worth to add it to upstream ;)

I reverted this change because it breaks current versions of mysql. You're going to have to find a different way to do this (or not use dashes).

cu12 commented

@josegonzalez Gotta love the way of how MySQL changes over time ;) I'll check it.

Going to close this, as the "fix" doesn't apply to new versions of mysql.