centos use docker install mysql
docker pull 鏡像
$ docker pull mysql:5.7.17
創(chuàng)建容器實(shí)例
$ docker run --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=***** -d mysql:5.7.17
使用客戶端連接mysql 報(bào)錯(cuò):2005 unknow mysqlserver host
進(jìn)入容器實(shí)例進(jìn)行測(cè)試
$ docker exec -it 2a7a85124400 /bin/bash
連接數(shù)據(jù)庫
$ mysql -h 127.0.0.1 -u root -p
root@cf9f8da7d928:~# mysql -h 127.0.0.1 -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.17 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, 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.
在容器實(shí)例中測(cè)試連接沒有問題杀怠,于是考慮防火墻問題,是否沒有開放 3306 端口铃剔。
使用客戶端重新連接mysql头滔。