docker 启动mysql
启动mysql报错,原因是没有设置环境变量,导制mysql无法进行初始化。
[root@master ~]# docker run --name mysql mysql
2020-01-05 15:05:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.
2020-01-05 15:05:38+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-01-05 15:05:38+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.18-1debian9 started.
2020-01-05 15:05:38+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
解决方法:增加-e参数,设置环境变量指定mysql密码
docker run --name mysql -e MYSQL_ROOT_PASSWORD=root mysql
[root@master ~]# docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql
ce4a61ffa748c3b0e5327fec3b92ad567a2da86d45fec67d75613cf32a43d65a