[ERROR] [Entrypoint]: Database is uninitialized and password option is not specified

问题描述:docker启动mysql失败

通过如下命令启动mysql时报错,具体如下所示

root@ecs-kc1-small-1-linux:~# docker run -p 3306:3306 mysql:8-oracle
2022-03-05 13:40:49+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1.el8 started.
2022-03-05 13:40:50+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2022-03-05 13:40:50+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1.el8 started.
2022-03-05 13:40:50+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
    You need to specify one of the following:
    - MYSQL_ROOT_PASSWORD
    - MYSQL_ALLOW_EMPTY_PASSWORD
    - MYSQL_RANDOM_ROOT_PASSWORD

经过查找相关资料,发现启动命令中缺少密码,由于使用的是Linux的root用户,因此将启动命令修改为如下所示

docker run --name mysql -d -it -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql:8-oracle

至此,mysql成功启动。通过docker ps命令可以看到正在运行的mysql。

你可能感兴趣的:(linux,docker,mysql)