MySQL,8:連接錯誤信息對應x
發(fā)布時間:2020-10-05 來源: 精準扶貧 點擊:
MySQL 8 :連接錯誤信息對應 這篇文章記錄一下在 MacOS 的 Catalina 版本下使用 MacOS 下安裝的 MySQL 8 在進行客戶端連接時所碰到的問題。
環(huán)境說明 • 操作系統(tǒng)版本: 10.15.2 liumiaocn:target liumiao$ sw_vers
ProductName:
Mac OS X
ProductVersion: 10.15.2
BuildVersion:
19C57
liumiaocn:target liumiao$
• MySQL 版本: 8.0.11 liumiaocn:target liumiao$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.
Commands end with ; or \g.
Your MySQL connection id is 46
Server version: 8.0.11 Homebrew
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type "help;" or "\h" for help. Type "\c" to clear the current input statement.
mysql>
• MySQL 運行狀態(tài) liumiaocn:target liumiao$ mysql.server status
SUCCESS! MySQL running (4633)
liumiaocn:target liumiao$
問題現(xiàn)象 使用 MySQL Workbench 的如下配置
點擊 Test Connection 時,提示如下錯誤信息
原因 MySQL 8 中的認證方式發(fā)生了變化
使用如下 SQL 即可確認當前 root 用戶的認證方式:
mysql> SELECT Host, User, plugin from mysql.user;
+-----------+------------------+-----------------------+
| Host
| User
| plugin
|
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | mysql_native_password |
| localhost | mysql.session
| mysql_native_password |
| localhost | mysql.sys
| mysql_native_password |
| localhost | root
| caching_sha2_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
mysql>
對應方法 最簡單的方式莫過于直接修改,比如使用如下 SQL 即可 mysql> ALTER USER "root"@"localhost" IDENTIFIED WITH mysql_native_password BY "liumiao123";
Query OK, 0 rows affected (0.03 sec)
mysql>
確認完之后再次確認結果 mysql> SELECT Host, User, plugin from mysql.user;
+-----------+------------------+-----------------------+
| Host
| User
| plugin
|
+-----------+------------------+-----------------------+
| localhost | mysql.infoschema | mysql_native_password |
| localhost | mysql.session
| mysql_native_password |
| localhost | mysql.sys
| mysql_native_password |
| localhost | root
| mysql_native_password |
+-----------+------------------+-----------------------+
4 rows in set (0.00 sec)
mysql>
當然,直接修改 MySQL 的配置文件,然后重新啟動也可以設定成功,而且設定會持久保存。
[mysqld]
default_authentication_plugin=mysql_native_password
結果確認 此時使用 MySQL Workbench 再次連接,Test Connection 即可正常動作了。
正確輸入上述修改的密碼之后,即可顯示連接成功了。
熱點文章閱讀