Docker 安装 Mysql 报错(2059) Authentication plugin ‘caching_sha2_password‘ 解决方案
1 .docker 安装mysql
# 下载mysql镜像
1. docker pull mysql:latest
# 启动mysql
2. docker run -p 3306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD=root -d mysql
#进入容器内部
3.docker exec -it mysqltest bash
4.容器内部> mysql -u root -p
进行测试
2. 连接报错 (2059) Authentication plugin ‘caching_sha2_password’
解决方案
- ALTER USER ‘root’ IDENTIFIED WITH mysql_native_password BY ‘root’
root@eccee808c07d:/etc/mysql# mysql --user=root --password
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.27 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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> ALTER USER 'root' IDENTIFIED WITH mysql_native_password BY 'root'
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
即可完美解决
本文作者:张三Blog
本文链接:https://www.cnblogs.com/zhangsan-plus/p/16503254.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步