Docker MySQL
1、Docker拉取MySQL镜像
# docker pull mysql:5.7
2、Docker运行MySQL
[root@fcant-hadoop002 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@fcant-hadoop002 ~]# docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 e1e1680ac726
8aa1b356648e8e54ff01475a9412c1669021540ca8b7f8225808af4c55be4160
[root@fcant-hadoop002 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8aa1b356648e e1e1680ac726 "docker-entrypoint..." 6 seconds ago Up 6 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
[root@fcant-hadoop002 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/mysql 5.7 e1e1680ac726 2 weeks ago 373 MB
3、连接测试
4、MySQL8.0使用navicat连接方式升级不能连接问题
Q:2059 - Authentication plugin ‘caching_sha2_password’ cannot be loaded:??????
A:通过Docker进入容器的Bash更改数据库的连接方式
[root@fcant-hadoop002 ~]# docker exec -it mysql8 bash
root@599ce281ef9b:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.17 MySQL Community Server - GPL
Copyright (c) 2000, 2019, 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> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql>
S:连接成功