crystal-lang / crystal-mysql

MySQL connector for Crystal
MIT License
107 stars 36 forks source link

Support MySQL 8 #72

Open fernandes opened 5 years ago

fernandes commented 5 years ago

Thankfully now GH has the Draft Pull Request option, so no need to explicit it here šŸ˜‰

Some premises:

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? šŸ˜„

bcardiff commented 5 years ago

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.

fernandes commented 5 years ago

@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