MySQL8.0远程连接异常

547 阅读1分钟

Django后端连接用docker部署的MySQL8.0,报错异常

django.db.utils.OperationalError: (2059, "Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory")

进入容器内部

docker exec -it mysql /bin/bash

# 容器内部客户端连接mysql
mysql -u root -p******

# 查看当前mysql表的熟悉
mysql> select user, host, plugin from user where user='root';
+------+-----------+-----------------------+
| user | host      | plugin                |
+------+-----------+-----------------------+
| root | %         | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------+-----------+-----------------------+
2 rows in set (0.00 sec)

# 修改
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '******';
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '******';
Query OK, 0 rows affected (0.00 sec)