Reproduced, please indicate the source ^ _ ^
Original starting in: www.zhangruibin.com
This article comes from: RebornChang's blog
docker installation MySQL5.8
Download image
docker pull mysql
start up
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=YourPWD123! -d mysql
Note: If the unit is installed in a MySQL instance, then the time the need to first download the image MySQL then start a change of name, such as re-installed on the host MySQL5.6 bloggers, so direct use of the above command start time error. It should be as follows.
Modify Mirror named mysql2
docker tag mysql:latest mysql2:v2
After the start-modified image
docker run --name mysql2 -p 3307:3306 -e MYSQL_ROOT_PASSWORD=YourPWD12! -d mysql
注意端口不要跟本地的冲突
MySQL mirror Log
mysql -u root -p
执行命令之后输入对应的密码即可登录到镜像中的MySQL
View MySQL version
select version();
可以看到输出:
+-----------+
| version() |
+-----------+
| 8.0.16 |
+-----------+
1 row in set (0.02 sec)
modify
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘YourPWD12!’;
Add Telnet user
CREATE USER ‘rebornchang’@’%’ IDENTIFIED WITH mysql_native_password BY ‘YourPWD12!’;
GRANT ALL PRIVILEGES ON . TO ‘rebornchang’@’%’;
Opening the corresponding port (iptables)
1.编辑文件
vim /etc/sysconfig/iptables
2.增加内容
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3307 -j ACCEPT
3.重启生效
service iptables restart
Test Connection
After testing, the connection is successful:
It is worth mentioning that, when this started MySQL5.8 example mirrored inside, local bloggers installed MySQL5.6 not be used, back under study where the problem is.