国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務(wù)器 > Web服務(wù)器 > 正文

Mac上使用Docker如何快速啟動(dòng)MySQL測(cè)試

2024-09-01 13:48:22
字體:
供稿:網(wǎng)友

本文主要討論使用Docker快速啟動(dòng) MySQL 測(cè)試的方法,包括Mac環(huán)境。一起看看吧!

近來業(yè)界有很多對(duì)Docker的討論,其生態(tài)系統(tǒng)發(fā)展得很快,然而,從簡(jiǎn)單的“入門”或“引導(dǎo)”類的文章中能容易地找到成熟的技術(shù),但Docker不然。我在Mac上試玩過Docker,但Mac絕對(duì)是Docker界的二等公民。當(dāng)我在Giuseppe的博客上看到關(guān)于在Mac上使用新Docker beta《Docker for Mac beta and MySQL》一文時(shí),決定自己來嘗試下。這些步驟適用于Mac(Windows也可能),亦能適配Linux環(huán)境(GA版本,Docker 1.11.1)。

首先,在Mac上注冊(cè)新的Docker測(cè)試版程序,接著從Docker中獲得下載代碼。此過程我耗時(shí)一天,但應(yīng)該不久就會(huì)發(fā)布完整版。安裝完成后,我需要為常見的MySQL版本設(shè)置一些Docker容器,沙箱也就有了。方法如下:

jayj@~ [510]$ docker network create test90005b3ffa9fef1f817ee4965e794a567404c9a8d5bf07320514e7d848d59ff9jayj@~ [511]$ docker run --name=mysql57 --net=test -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql/mysql-server:5.76c80fa89610dbd5418ba474ad7d5451cd061f80a8a72ff2e718341827a08144bjayj@~ [512]$ docker run -it --rm --net=test -e MYSQL_HOST=mysql57 mysql/shell initCreating a Classic Session to root@mysql57:3306Enter password:No default schema selected.enableXProtocol: Installing plugin mysqlx...enableXProtocol: done

一些經(jīng)驗(yàn)總結(jié):

我為我的容器創(chuàng)建了一個(gè)名為“測(cè)試”的網(wǎng)絡(luò)以共享,本質(zhì)是容器之間一個(gè)專用的私有網(wǎng)絡(luò)。我喜歡這個(gè)是因?yàn)樵谙嚓P(guān)的端口是監(jiān)聽多個(gè)容器,也不必設(shè)置主機(jī)操作系統(tǒng)的端口。
我將Oracle的官方MySQL Docker容器啟動(dòng)一個(gè)MySQL 5.7的鏡像,在綁定到該測(cè)試網(wǎng)絡(luò)。

我使用了MySQL /shell鏡像(來自O(shè)racle)來初始化MySQL 5.7服務(wù)器上的mysqlx插件。需要注意的是,我并沒有輸入密碼,因?yàn)槲覜]有創(chuàng)建一個(gè)服務(wù)器(不安全,但它是一個(gè)沙箱)。
這個(gè)里面的Shell使用了運(yùn)行后刪除的臨時(shí)容器,所以并不會(huì)破壞Docker ps-a輸出。

所以,現(xiàn)在我希望能夠使用標(biāo)準(zhǔn)的MySQL命令行或新的MySQL shell來訪問這個(gè)容器。讓它看起來很干凈,因此我添加了一些bash別名:

alias mysqlsh='docker run -it --rm --net=test mysql/shell'alias mysql='docker run -it --rm -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --net=test --entrypoint="mysql" mysql/mysql-server:5.7'

這些以后,我可以直接調(diào)用他們并通過正常的命令行選項(xiàng)來連接我的MySQL 5.7鏡像,就像使用的是一個(gè)原生的MySQL CLI binary。從MySQL 5.7鏡像中使用MySQL CLI:

jayj@~ [524]$ mysql -h mysql57Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 4Server version: 5.7.12 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.mysql> show schemas;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.01 sec)

使用MySQL shell:

jayj@~ [527]$ mysqlsh -h mysql57 -u root --session-type=nodeCreating a Node Session to root@mysql57:33060Enter password:No default schema selected.Welcome to MySQL Shell 1.0.3 Development PreviewCopyright (c) 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help', 'h' or '?' for help.Currently in JavaScript mode. Use sql to switch to SQL mode and execute queries.mysql-js> sqlSwitching to SQL mode... Commands end with ;mysql-sql> show schemas;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)mysql-sql>

現(xiàn)在,如果為了一些事情想要運(yùn)行檢查MySQL 5.5,可以這樣做:

jayj@~ [530]$ docker run --name=mysql55 --net=test -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql/mysql-server:5.5Unable to find image 'mysql/mysql-server:5.5' locally5.5: Pulling from mysql/mysql-servera3ed95caeb02: Already existsffe36b360c6d: Already exists646f220a8b5d: Pull completeed65e4fea7ed: Pull completed34b408b18dd: Pull completeDigest: sha256:12f0b7025d1dc0e7b40fc6c2172106cdf73b8832f2f910ad36d65228d9e4c433Status: Downloaded newer image for mysql/mysql-server:5.56691dd9d42c73f53baf2968bcca92b7f4d26f54bb01d967be475193305affd4fjayj@~ [531]$ mysql -h mysql55Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1Server version: 5.5.49 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.mysql> show schemas;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema |+--------------------+3 rows in set (0.00 sec)或者,Percona Server:jayj@~ [534]$ docker run --name=ps57 --net=test -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d percona/percona-server:5.7Unable to find image 'percona/percona-server:5.7' locally5.7: Pulling from percona/percona-servera3ed95caeb02: Pull completea07226856d92: Pull completeeee62d87a612: Pull complete4c6755120a98: Pull complete10eab0da5972: Pull completed5159a6502a4: Pull completee595a1a01d00: Pull completeDigest: sha256:d57f0ce736f5403b1714ff8d1d6b91d5a7ee7271f30222c2bc2c5cad4b4e6950Status: Downloaded newer image for percona/percona-server:5.79db503852747bc1603ab59455124663e8cedf708ac6d992cff9b43e2fbebd167jayj@~ [537]$ mysql -h ps57Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 2Server version: 5.7.10-3 Percona Server (GPL), Release 3, Revision 63dafafCopyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.mysql>

所以,這一切都很好,一旦鏡像被本地緩存,上下調(diào)整新的容器可以實(shí)現(xiàn)無痛和快速。所有這一切的工作都是與我的操作系統(tǒng)工作站分離的。可能還有其他事情可以使用這種設(shè)置,但還沒找到方法(如加載數(shù)據(jù)文件、運(yùn)行代碼來連接這些容器等),但將來我會(huì)解決。

以上所述是小編給大家介紹的Mac上使用Docker快速啟動(dòng)MySQL測(cè)試的方法,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)VEVB武林網(wǎng)網(wǎng)站的支持!


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 额济纳旗| 济南市| 盈江县| 乐东| 勃利县| 永善县| 密云县| 磐安县| 上犹县| 凤庆县| 宁海县| 綦江县| 宜丰县| 建水县| 双鸭山市| 睢宁县| 普兰县| 乌拉特前旗| 阿克陶县| 大庆市| 南康市| 古田县| 苏州市| 民权县| 松溪县| 酉阳| 安陆市| 安图县| 巴里| 舒城县| 介休市| 绿春县| 武义县| 廉江市| 胶州市| 宁阳县| 楚雄市| 木兰县| 青田县| 二连浩特市| 剑川县|