Use docker to install mysql. After starting the container, mysql does not start.
世界只因有你
世界只因有你 2017-05-24 11:35:50
0
2
1121

1. Installation

docker run -it -p 3306:3306 --name mysql1 -v ~/mysql/conf/my.cnf:/etc/mysql/my.cnf -v ~/mysql/logs:/logs -v ~/mysql/data:/mysql_data -e MYSQL_ROOT_PASSWORD=123456 -d docker.io/mysql  /bin/bash

2. Container startup

3. After entering the container using attach, I did not see the mysql process

世界只因有你
世界只因有你

reply all(2)
仅有的幸福

1. It is not recommended to mount files directly, generally mount folders

2. After entering the container, manually execute the command docker-entrypoint.sh and see what error message is output

某草草

1. It means that your mysql has not been started, because your /bin/bash has already exposed the problem.

2. Try starting like this

$docker run -d mysql
$docker exec -it $container_id /bin/bash

You can understand the cause of the problem by reading the official description of CMD and entrypoint instructions.

The following is my test result

#1.模拟你得效果,这里不会报错,是因为没有执行mysqld进行初始化,bash已经覆盖了指令
docker@default:~$ docker run -it mysql bash
root@8b767c162afd:/# ps -aux | grep mysql
root         7  0.0  0.0  11128   984 ?        S+   03:04   0:00 grep mysql

#2.报错,因为没有加-e环境参数,说明mysqld执行了初始化,未找到环境变量
docker@default:~$ docker run -d mysql
9212525aedf8f5586548fbc1d1e4fa130fd0ce294ac03c2d00a1c1d9945455a5
docker@default:~$ docker exec -it 92 bash
Error response from daemon: Container 9212525aedf8f5586548fbc1d1e4fa130fd0ce294ac03c2d00a1c1d9945455a5 is not running
                                   mysql-db
docker@default:~$ docker logs 92
error: 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
docker@default:~$
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!