How to install mysql based on docker in Linux

安裝

Step 1
You need to clone the code from mysql-docker-inner-node73.

Step 2
Copy the directory data to the root directory /.

Step 3
Execute the following initialization script.

  主機上的mysql服務是基於docker安裝的,具體安裝腳本如下:

docker run --detach \
--restart always \
--publish 3306:3306 \
--name mysql \
--volume /data/docker/mysql/data:/var/lib/mysql \
--volume /data/docker/mysql/etc:/etc/mysql \
--env MYSQL_ROOT_PASSWORD=***** \
mysql:8.0.19
docker run --detach \
--restart always \
--publish 3306:3306 \
--name mysql \
--volume /data/docker/mysql/data:/var/lib/mysql \
--volume /data/docker/mysql/etc:/etc/mysql \
--env MYSQL_ROOT_PASSWORD=***** \
mysql:8.0.19

重啓

docker restart mysql

關閉

docker stop mysql

卸載

docker rm mysql

訪問

lwk@qwfys:~$ mysql -h cvm00.xtwj.com -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 4
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

mysql> 

Reference

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章