Browse Source

Clarifications for usage with MySQL 8

* Add notes in README about unsupported `caching_sha2_password`.
* Remove `NO_AUTO_CREATE_USER` from `SQL_MODE` as it doesn't exist
  anymore.
Viktor Söderqvist 6 years ago
parent
commit
987c470dd0
4 changed files with 20 additions and 14 deletions
  1. 4 2
      .travis.yml
  2. 11 3
      README.md
  3. 1 1
      test/mysql_tests.erl
  4. 4 8
      test/ssl_tests.erl

+ 4 - 2
.travis.yml

@@ -10,8 +10,10 @@ before_script:
   - cat test/ssl/my-ssl.cnf | sudo tee -a /etc/mysql/conf.d/my-ssl.cnf
   - sudo service mysql start
   - sleep 5
-  - mysql -uroot -e "grant all privileges on otptest.* to otptest@localhost identified by 'otptest'"
-  - mysql -uroot -e "grant all privileges on otptestssl.* to otptestssl@localhost identified by 'otptestssl' require ssl"
+  - mysql -uroot -e "CREATE USER otptest@localhost IDENTIFIED BY 'otptest';"
+  - mysql -uroot -e "GRANT ALL PRIVILEGES ON otptest.* TO otptest@localhost;"
+  - mysql -uroot -e "CREATE USER otptestssl@localhost IDENTIFIED BY 'otptestssl';"
+  - mysql -uroot -e "GRANT ALL PRIVILEGES ON otptest.* TO otptestssl@localhost REQUIRE SSL;"
 script: 'make tests'
 otp_release:
   - 21.1

+ 11 - 3
README.md

@@ -31,6 +31,10 @@ Requirements:
   pattern matching. This was fixed in OTP 21.1.
 * MySQL database version 4.1 or later or MariaDB
 * No other dependencies
+* Authentication method `caching_sha2_password` is not supported. This is the
+  default in MySQL 8.0.4 and later, so you need to add
+  `default_authentication_plugin=mysql_native_password` under `[mysqld]` in e.g.
+  `/etc/mysql/my.cnf`.
 
 Synopsis
 --------
@@ -39,7 +43,8 @@ Synopsis
 %% Connect (ssl is optional)
 {ok, Pid} = mysql:start_link([{host, "localhost"}, {user, "foo"},
                               {password, "hello"}, {database, "test"},
-                              {ssl, [{cacertfile, "/path/to/ca.pem"}]}]),
+                              {ssl, [{server_name_indication, disable},
+                                     {cacertfile, "/path/to/ca.pem"}]}]),
 
 %% Select
 {ok, ColumnNames, Rows} =
@@ -110,8 +115,11 @@ start MySQL on localhost and give privileges to the user `otptest` and (for
 `ssl_tests`) to the user `otptestssl`:
 
 ```SQL
-grant all privileges on otptest.* to otptest@localhost identified by 'otptest';
-grant all privileges on otptest.* to otptestssl@localhost identified by 'otptestssl' require ssl;
+CREATE USER otptest@localhost IDENTIFIED BY 'otptest';
+GRANT ALL PRIVILEGES ON otptest.* TO otptest@localhost;
+
+CREATE USER otptestssl@localhost IDENTIFIED BY 'otptestssl';
+GRANT ALL PRIVILEGES ON otptest.* TO otptestssl@localhost REQUIRE SSL;
 ```
 
 Before running the test suite `ssl_tests` you'll also need to generate SSL files

+ 1 - 1
test/mysql_tests.erl

@@ -29,7 +29,7 @@
 
 %% We need to set a the SQL mode so it is consistent across MySQL versions
 %% and distributions.
--define(SQL_MODE, <<"NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER">>).
+-define(SQL_MODE, <<"NO_ENGINE_SUBSTITUTION">>).
 
 -define(create_table_t, <<"CREATE TABLE t ("
                           "  id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,"

+ 4 - 8
test/ssl_tests.erl

@@ -1,5 +1,6 @@
 %% MySQL/OTP – MySQL client library for Erlang/OTP
-%% Copyright (C) 2017 Piotr Nosek, Viktor Söderqvist
+%% Copyright (C) 2017 Piotr Nosek
+%% Copyright (C) 2017-2018 Viktor Söderqvist
 %%
 %% This file is part of MySQL/OTP.
 %%
@@ -24,16 +25,11 @@
 -define(ssl_user,     "otptestssl").
 -define(ssl_password, "otptestssl").
 -define(cacertfile,   "test/ssl/ca.pem").
--define(certfile,     "test/ssl/server-cert.pem").
--define(keyfile,      "test/ssl/server-key.pem").
 
 successful_ssl_connect_test() ->
     [ application:start(App) || App <- [crypto, asn1, public_key, ssl] ],
-    common_basic_check([{ssl, [
-                        {server_name_indication, disable}, 
-                        {cacertfile, ?cacertfile}]},
-                        {certfile, ?certfile},
-                        {keyfile, ?keyfile},
+    common_basic_check([{ssl, [{server_name_indication, disable},
+                               {cacertfile, ?cacertfile}]},
                         {user, ?ssl_user}, {password, ?ssl_password}]),
     common_conn_close(),
     ok.