crystal-mysql icon indicating copy to clipboard operation
crystal-mysql copied to clipboard

Support MySQL 8

Open fernandes opened this issue 5 years ago • 2 comments

Thankfully now GH has the Draft Pull Request option, so no need to explicit it here 😉

Some premises:

  • I couldn't manage the driver to connect without password on MySQL 8, so I had to change the spec_helper to accept a password
  • I changed the driver_spec to make the test more robust, with some DROP IF EXISTS
  • As secret is considered a weak password on MySQL 8, I set the 3 globals to allow secret as a password for the user
  • MySQL 8 does not allow creating a user on GRANT call, so I split in two, first CREATE USER then GRANT

The ~workaround~ fix for #62 is the removal on src/mysql/packets; not sure about the (likely) bad impact on MySQL 5 versions

Here on my machine, to run the tests, I created the user on DB

CREATE USER 'crystal_mysql_spec'@'localhost' IDENTIFIED WITH mysql_native_password BY 'crystal_mysql_spec';
GRANT ALL PRIVILEGES ON *.* TO 'crystal_mysql_spec'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

then

DATABASE_USER="crystal_mysql_spec" crystal spec

So yeah, here is what I could manage to do, any idea where we can go next? 😄

fernandes avatar Mar 02 '19 14:03 fernandes

I would not drop the empty password support. Maybe the default installation of MySQL 8 has non-empty root password and can be tweaked (https://medium.com/@benmorel/remove-the-mysql-root-password-ba3fcbe29870, https://stackoverflow.com/questions/48824572/mysql-8-0-unable-to-reset-root-password).

Please update the travis.yml to include MySQL 8.

If "secret" bothers as a password, use any other constant value and that's it. Let's avoid changing the rules. Not everybody will run an isolated db server.

bcardiff avatar Mar 02 '19 16:03 bcardiff

@bcardiff thanks for the reply! :)

my mysql root user has no password, the problem happens when use crystal-mysql with the following connection URI:

mysql://root@#{database_host}/#{initial_db}

MySQL driver does not play well with MySQL 8 when using no password, so I got this error:

Unhandled exception: Client does not support authentication protocol requested by server; consider upgrading MySQL client (Exception) as reported on #56 , no idea how to solve here

For the secret, just used a "stronger" password, and MySQL was happy

ps: I'm using a default MySQL 8 install on OSX

fernandes avatar Mar 02 '19 19:03 fernandes