日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 5.7 mirror_Centos7 Docker离线部署Mysql5.7

發布時間:2023/12/1 数据库 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 5.7 mirror_Centos7 Docker离线部署Mysql5.7 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1 環境信息

查看系統內核

[root@localhost /]# cat /etc/redhat-release

CentOS Linux release 7.5.1804 (Core)

2 虛擬機拉取鏡像

此處資源獲取在虛擬機中進行,完成后上傳到服務器安裝

2.1 拉取mysql5.7鏡像

[root@localhost /]# docker pull mysql:5.7

2.2 導出鏡像

[root@localhost /]# docker save -o /opt/module/software/jingxiang/mysql57.tar mysql:5.7

3 服務器加載鏡像

將提供的docker文件夾上傳到服務器的 /opt/module/software/jingxiang 目錄下

3.1 導入Mysql鏡像

[root@localhost /]# docker load -i /opt/module/software/jingxiang/mysql57.tar

99b5261d397c: Loading layer [==================================================>] 58.51 MB/58.51 MB

5a8a245abd1c: Loading layer [==================================================>] 338.4 kB/338.4 kB

51734435c93c: Loading layer [==================================================>] 10.44 MB/10.44 MB

6599033b2ab2: Loading layer [==================================================>] 4.472 MB/4.472 MB

414373ffccb4: Loading layer [==================================================>] 1.536 kB/1.536 kB

2a9aab74013a: Loading layer [==================================================>] 46.15 MB/46.15 MB

7055b7f82e4c: Loading layer [==================================================>] 34.3 kB/34.3 kB

398ef8a407f7: Loading layer [==================================================>] 3.584 kB/3.584 kB

fc12e028de3b: Loading layer [==================================================>] 321.7 MB/321.7 MB

934de0c0816e: Loading layer [==================================================>] 15.87 kB/15.87 kB

94a471180601: Loading layer [==================================================>] 1.536 kB/1.536 kB

Loaded image: mysql:5.7

[root@localhost docker]# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

mysql 5.7 1e4405fe1ea9 2 weeks ago 437 MB

3.2 創建容器

[root@localhost /]# docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

1fcf644fb24c4731f70ca66edc96847452e898de7612de05b4dd188b3965883c

run 運行一個docker容器

--name 后面這個是生成的容器的名字mysql

-p 3306:3306 表示這個容器中使用3306(第二個)映射到本機的端口號也為3306(第一個)

-e MYSQL_ROOT_PASSWORD=123456 初始化root用戶的密碼

-d 表示使用守護進程運行,即服務掛在后臺

[root@localhost docker]# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

1fcf644fb24c mysql:5.7 "docker-entrypoint..." 25 seconds ago Up 23 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp mysql

3.3 允許外部訪問

# 進入容器

[root@localhost docker]# docker exec -it mysql /bin/bash

root@1fcf644fb24c:/# mysql -uroot -p123456

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> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "123456";

mysql> flush privileges;

mysql> exit;

Bye

root@1fcf644fb24c:/# exit;

exit

3.4 啟動服務

[root@localhost docker]# docker start mysql

3.5 停止服務

[root@localhost docker]# docker stop mysql

3.6 服務信息

服務 mysql

版本 5.7

用戶名 root

密碼 123456

4 相關資源

總結

以上是生活随笔為你收集整理的mysql 5.7 mirror_Centos7 Docker离线部署Mysql5.7的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。