本篇內(nèi)容介紹了“docker安裝MySQL5.7的過(guò)程”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
創(chuàng)新互聯(lián)公司是一家專(zhuān)注于成都網(wǎng)站建設(shè)、網(wǎng)站建設(shè)與策劃設(shè)計(jì),東營(yíng)區(qū)網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)公司做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)十年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:東營(yíng)區(qū)等地區(qū)。東營(yíng)區(qū)做網(wǎng)站價(jià)格咨詢:13518219792
查找Docker Hub上的mysql鏡像:
[root@docker01 ~]# docker search mysql
以下是內(nèi)容輸出
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容器的幾種方法中,下面這種最常用,這種方法可以保證在退出的時(shí)候不會(huì)退出容器。
[root@docker01 mysql]# docker exec-it d98e /bin/bash
root@d98e86d6b54f:/#
在宿主機(jī)直接登錄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 |
這種方式是最簡(jiǎn)單的安裝方式,很多時(shí)候,我們把容器作為一個(gè)虛擬機(jī)來(lái)折騰,反而要比這樣安裝好玩一些。
“docker安裝mysql5.7的過(guò)程”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!