Docker启动 mysql8

北慕城南 提交于 2020-07-27 15:03:49

1. 创建MYSQL8

 docker run -it -d -p 3328:3306  --name  docker_8_3328_mysql -e MYSQL_ROOT_PASSWORD=密码  --privileged=true  --restart always -d  mysql:8

 

2.添加防火墙端口

firewall-cmd --permanent --zone=public  --add-port=3328/tcp

 

3.进入docker容器修改密码

 docker exec -it 5160bdcd9252 bash

 

4.修改docker容器mysql信息

root@5160bdcd9252:/# mysql -uroot -p密码
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 48
Server version: 8.0.20 MySQL Community Server - GPL

Copyright (c) 2000, 2020, 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 by '密码' password expire never;
Query OK, 0 rows affected (0.02 sec)

mysql> alter user 'root'@'%' identified with mysql_native_password by  '密码';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!