日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

秒級搭建MySQL數(shù)據(jù)庫服務(wù),太香了
需求

在一些項(xiàng)目現(xiàn)場,很多時(shí)候,都是缺少專門的數(shù)據(jù)庫運(yùn)維人員的,但是開發(fā)人員開發(fā)項(xiàng)目,又需要用到MySQL數(shù)據(jù)庫服務(wù)器,而且不同的項(xiàng)目的數(shù)據(jù)庫又要分開

秒級搭建MySQL數(shù)據(jù)庫服務(wù),太香了

項(xiàng)目需求

解決方案

對于非數(shù)據(jù)庫運(yùn)維人員,安裝MySQL數(shù)據(jù)庫有一定的難度,所以在這里推薦用Docker來搭建MySQL數(shù)據(jù)庫服務(wù)。這種方案門檻低,對于非數(shù)據(jù)庫專業(yè)人員也能秒級搭建好一條MySQL服務(wù)。

搭建步驟

拉取MySQL數(shù)據(jù)庫鏡像

docker pull mysql:latest

直接執(zhí)行這個命令,意思是拉取最新的鏡像,但是實(shí)際項(xiàng)目可能需要制定的數(shù)據(jù)庫版本,所以這里需要制定標(biāo)簽,拉取需要的鏡像

docker pull mysql:5.7.28
秒級搭建MySQL數(shù)據(jù)庫服務(wù),太香了

 

創(chuàng)建MySQL容器

拉取好鏡像之后,就可以創(chuàng)建2個MySQL容器了,對外訪問端口為3306,3307

[root@localhost ~]# docker run --name mysql5.7.28_3306 -e MYSQL_ROOT_PASSword=root -p 3306:3306 -d -it mysql:5.7.28
423e39a1c8669a53942aed14002102adbb8871c47edfbaa67825691eb16d0d45
[root@localhost ~]# docker run --name mysql5.7.28_3307 -e MYSQL_ROOT_PASSWORD=root -p 3307:3306 -d -it mysql:5.7.28
ff668e421d59b1fef61d58b70532bf87d5915da1c47d63db690857d74d283e12
[root@localhost ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS              PORTS                               NAMES
ff668e421d59        mysql:5.7.28        "docker-entrypoint.s鈥 29 seconds ago       Up 27 seconds       33060/tcp, 0.0.0.0:3307->3306/tcp   mysql5.7.28_3307
423e39a1c866        mysql:5.7.28        "docker-entrypoint.s鈥 About a minute ago   Up About a minute   0.0.0.0:3306->3306/tcp, 33060/tcp   mysql5.7.28_3306

這樣2個容器就創(chuàng)建好了,只是用docker ps顯示的結(jié)果被截?cái)嗔耍粔蛴押茫梢杂孟旅娴拿睿瑏碚故灸阈枰吹降牧行畔⒕秃?/p>

[root@localhost ~]# docker ps --format "table {{.ID}}t{{.Image}}t{{.Names}}t{{.Ports}}t{{.RunningFor}}t{{.Status}}"
CONTAINER ID        IMAGE               NAMES               PORTS                               CREATED              STATUS
ff668e421d59        mysql:5.7.28        mysql5.7.28_3307    33060/tcp, 0.0.0.0:3307->3306/tcp   About a minute ago   Up About a minute
423e39a1c866        mysql:5.7.28        mysql5.7.28_3306    0.0.0.0:3306->3306/tcp, 33060/tcp   2 minutes ago        Up 2 minutes

MySQL服務(wù)測試

驗(yàn)證端口

[root@localhost ~]# netstat -an|egrep "3306|3307"
tcp6       0      0 :::3306                 :::*                    LISTEN     
tcp6       0      0 :::3307                 :::*                    LISTEN     

可以看到,3306和3307端口已經(jīng)開啟。


MySQL客戶端連接測試

[mysql@localhost ~]$ mysql -uroot -proot -h 192.168.17.128 -P 3306
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
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> quit
Bye
[mysql@localhost ~]$ 
[mysql@localhost ~]$ mysql -uroot -proot -h 192.168.17.128 -P 3307
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
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> quit

可以看到,兩個MySQL數(shù)據(jù)庫服務(wù)已經(jīng)搭建好了,整個搭建都不到1分鐘。

分享到:
標(biāo)簽:MySQL
用戶無頭像

網(wǎng)友整理

注冊時(shí)間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運(yùn)動步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定