[root@localhost zhi-docker]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES abcf3396c4fc free4inno/zhi-web:2.0.0 "/bin/bash /usr/loca…" 3 hours ago Up 3 hours 0.0.0.0:8081->8081/tcp, :::8081->8081/tcp, 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp, 0.0.0.0:8888->80/tcp, :::8888->80/tcp zhi-web f5b9ee19dffa free4inno/zhimysql:1.1 "/entrypoint.sh --ch…" 3 hours ago Up 3 hours (healthy) 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp zhimysql 61fbe4b00515 bolingcavalry/elasticsearch-with-ik:6.5.0 "/usr/local/bin/dock…" 3 hours ago Up 3 hours 0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp zhies-node-1 69a731c44ff7 bolingcavalry/elasticsearch-head:6 "grunt server" 3 hours ago Up 3 hours 0.0.0.0:9100->9100/tcp, :::9100->9100/tcp zhies-head [root@localhost zhi-docker]# docker run zhimysql Unable to find image 'zhimysql:latest' locally
[root@localhost zhi-docker]# docker exec -it zhimysql bash bash-4.2# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 947 Server version: 8.0.18 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> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select user,plugin from user where user='root'; +------+-----------------------+ | user | plugin | +------+-----------------------+ | root | caching_sha2_password | +------+-----------------------+ 1 row in set (0.00 sec) mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | root | % | | healthchecker | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | +------------------+-----------+ 5 rows in set (0.00 sec) mysql> alter user 'root'@'%' identified with mysql_native_password by '123456'; Query OK, 0 rows affected (0.01 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
然后使用客户端连接数据库测试