当前位置:网站首页>Alibaba cloud server docker installation mysql5.5

Alibaba cloud server docker installation mysql5.5

2022-07-06 16:56:00 LuckyShawn

1.docker pull mysql Pull the mirror image

Personal feeling mysql5.5 The version is relatively stable , So choose 5.5 edition
Enter the command to download mysql5.5 Image of version

docker pull mysql:5.5

 Insert picture description here

2. adopt docker image You can view the pulled image

  docker images | grep mysql   see mysql Mirror image 

 Insert picture description here

3. function mysql Containers

docker run -p 3306:3306 --name shawnmysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD= Input password  -d mysql:5.5

Command specification :

-p 3306:3306: The container of 3306 Port mapping to host's 3306 port .

-v $PWD/conf:/etc/mysql/conf.d: Will host the current directory of conf/my.cnf Attached to the container /etc/mysql/my.cnf.

-v $PWD/logs:/logs: Will host the current directory of logs The directory is attached to the container's /logs.

-v $PWD/data:/var/lib/mysql : Will host the current directory of data The directory is attached to the container's /var/lib/mysql .

-e MYSQL_ROOT_PASSWORD=123456: initialization root User's password .

4. View the running container

docker ps

 Insert picture description here

5. Enter container enter mysql

docker exec -it containerId /bin/bash

 Insert picture description here
You can operate the database directly
complete !

原网站

版权声明
本文为[LuckyShawn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131313123943.html