【MySQL】5.6.x sha256_password外掛登入使用者時報錯

神諭丶發表於2016-08-18
【問題描述】:
版本:Oracle MySQL 5.6.30


新增default-authentication-plugin=sha256_password啟動引數啟動資料庫:
  1. mysqld_safe --default-authentication-plugin=sha256_password &
或在[mysqld]中設定default-authentication-plugin=sha256_password,並啟動資料庫。

檢視一下old_passwords選項:
  1. mysql> SELECT @@old_passwords;
  2. +-----------------+
  3. | @@old_passwords |
  4. +-----------------+
  5. | 0               |
  6. +-----------------+
  7. 1 row in set (0.00 sec)

建立測試使用者並重新整理授權表:
  1. mysql> CREATE USER aa@localhost IDENTIFIED BY 'aa';
  2. Query OK, 0 rows affected (0.01 sec)

  3. mysql> FLUSH PRIVILEGES;
  4. Query OK, 0 rows affected (0.00 sec)

登出,通過新建立好的使用者嘗試登入:
  1. [root@sAno1y ~]# mysql -uaa -paa
  2. Warning: Using a password on the command line interface can be insecure.
  3. ERROR 2061 (HY000): Authentication plugin 'sha256_password' reported error: Authentication requires SSL encryption

關閉例項,不加該引數重啟:
  1. mysqld_safe &
或在[mysqld]中刪除/註釋掉default-authentication-plugin=sha256_password選項,並啟動資料庫。

繼續嘗試登入:

  1. [root@sAno1y ~]# mysqld_safe &
  2. [1] 14052
  3. [root@sAno1y ~]# 160818 11:54:08 mysqld_safe Logging to '/data/mysql_log/err-log.err'.
  4. 160818 11:54:08 mysqld_safe Starting mysqld daemon with databases from /data/mysql

  5. [root@sAno1y ~]# mysql -uaa -paa
  6. Warning: Using a password on the command line interface can be insecure.
  7. ERROR 2061 (HY000): Authentication plugin 'sha256_password' reported error: Authentication requires SSL encryption

繼續報同樣的錯誤。

【解決方案】:
https://bugs.mysql.com/ 中找到這樣一個帖子:

https://bugs.mysql.com/bug.php?id=68478
目前該“bug”的Status已經被置為:Closed

結貼的是一個叫Paul Dubois的小哥的評論,他表示這並不是一個bug,因為bug提交者和我一樣,使用該外掛時,需要通過SSL連線:
Use of the sha256_password plugin requires that MySQL be built with SSL capabilities. See Section 6.3.9, “Using SSL for Secure Connections”.

反之:如果用了該外掛,又是用old_passwords=0的方式設定的密碼,那麼又何必多此一舉使用該外掛呢?
禁用該外掛並重新建立需要建立的user@ip即可解決問題。
前提是其他的使用者密碼也是沒有通過old_passwords=2的方式建立的。


作者微信公眾號(持續更新)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29773961/viewspace-2123662/,如需轉載,請註明出處,否則將追究法律責任。

相關文章