溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

docker安裝mysql5.7的過(guò)程

發(fā)布時(shí)間:2021-08-09 11:32:00 來(lái)源:億速云 閱讀:149 作者:chen 欄目:大數(shù)據(jù)

本篇內(nèi)容介紹了“docker安裝mysql5.7的過(guò)程”的有關(guān)知識(shí),在實(shí)際案例的操作過(guò)程中,不少人都會(huì)遇到這樣的困境,接下來(lái)就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

查找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)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI