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
即可完美解决