原创

docker安装mysql5.6

1.直接安装

1.执行命令安装 docker pull xxx

ZBMAC-C02WD12BH:mysql56 lishihao$ docker pull mysql:5.6
5.6: Pulling from library/mysql
8f91359f1fff: Pull complete 
6bbb1c853362: Pull complete 
e6e554c0af6f: Pull complete 
.....
327b60c1a0e5: Pull complete 
Digest: sha256:07ebe49dc810444e172c2b5a72ae1a23ad9f4942bfe70a7f0a578590da610579
Status: Downloaded newer image for mysql:5.6
docker.io/library/mysql:5.6
#安装完成

ZBMAC-C02WD12BH:mysql56 lishihao$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              d7c3d90fb9f6        14 hours ago        776MB
mysql               5.6                 95e0fc47b096        4 days ago          257MB
ubuntu              latest              a2a15febcdf3        4 weeks ago         64.2MB

2.启动mysql

1.报错解决

ZBMAC-C02WD12BH:mysql56 lishihao$ docker run -e MYSQL_ROOT_PASSWORD=123456 95e0fc47b096  -p 3306:3306

ERROR: mysqld failed while attempting to check config
command was: "mysqld -p 3306:3306 --verbose --help --log-bin-index=/tmp/tmp.0X9tri6Kzw"

2019-09-17 01:34:31 0 [Note] mysqld (mysqld 5.6.45) starting as process 9 ...
2019-09-17 01:34:31 9 [Note] Plugin 'FEDERATED' is disabled.
mysqld: Table 'mysql.plugin' doesn't exist
2019-09-17 01:34:31 9 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2019-09-17 01:34:31 9 [ERROR] mysqld: unknown option '-p'
2019-09-17 01:34:31 9 [ERROR] Aborting

2019-09-17 01:34:31 9 [Note] Binlog end
2019-09-17 01:34:31 9 [Note] Shutting down plugin 'MyISAM'
2019-09-17 01:34:31 9 [Note] Shutting down plugin 'CSV'
Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

这个错误当时解决实际挺长了 局域网内试了 好多 都不行,在so找到了可行的方案
将启动命令
docker run -e MYSQL_ROOT_PASSWORD=123456 95e0fc47b096 -p 3306:3306
改为
docker run -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 95e0fc47b096 即可

2.启动

ZBMAC-C02WD12BH:dockerf lishihao$ docker run -e MYSQL_ROOT_PASSWORD=123456  -p 3307:3306 95e0fc47b096
.....
2019-09-17 01:41:12 1 [Note] Server socket created on IP: '::'.
2019-09-17 01:41:12 1 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-09-17 01:41:12 1 [Warning] 'proxies_priv' entry '@ root@3adf3e4378ec' ignored in --skip-name-resolve mode.
2019-09-17 01:41:12 1 [Note] Event Scheduler: Loaded 0 events
2019-09-17 01:41:12 1 [Note] mysqld: ready for connections.
Version: '5.6.45'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

这就启动完成了

正文到此结束
本文目录