您好,登錄后才能下訂單哦!
本篇內容介紹了“docker安裝mysql5.7的過程”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
查找Docker Hub上的mysql鏡像:
[root@docker01 ~]# docker search mysql
以下是內容輸出
NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 6498 [OK] mariadb MariaDB is a community-developed fork of MyS… 2049 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 475 [OK] percona Percona Server is a fork of the MySQL relati… 344 [OK] zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 106 [OK] hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 88
|
[root@docker01~]# docker pull mysql:5.7
5.7: Pulling from library/mysql 683abbb4ea60: Downloading [===============================================> ] 21.16MB/22.5MB 0550d17aeefa: Download complete 7e26605ddd77: Download complete 9882737bd15f: Download complete 999c06ab75f6: Download complete c71d695f9937: Download complete c38f847c1491: Download complete 74f9c61f40bf: Download complete 30b252a90a12: Downloading [======> ] 11.2MB/83.46MB 9f92ebb7da55: Download complete 90303981d276: Download complete
|
[root@docker01 mysql]# docker run -p3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/mysql_data-e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7
d98e86d6b54fae37a1aff3b9f0fb04d5146936b4ce5f2b2c059043035d1b96e9
[root@docker01 mysql]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d98e86d6b54f mysql:5.7 "docker-entrypoint.s…" About a minute ago Up About aminute 0.0.0.0:3306->3306/tcp mymysql
登錄docker容器:
登錄docker容器的幾種方法中,下面這種最常用,這種方法可以保證在退出的時候不會退出容器。
[root@docker01 mysql]# docker exec-it d98e /bin/bash
root@d98e86d6b54f:/#
在宿主機直接登錄mysql
[root@docker01 mysql]# mysql -uroot-p123456 -h 172.17.0.1
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22 MySQLCommunity Server (GPL)
Copyright (c) 2000, 2017, Oracle,MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type'\c' to clear the current input statement.
MySQL [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
這種方式是最簡單的安裝方式,很多時候,我們把容器作為一個虛擬機來折騰,反而要比這樣安裝好玩一些。
“docker安裝mysql5.7的過程”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。