Docker系列之Docker安裝MySQL5.7.24

需求

在Docker下安裝項目所依賴的MySQL5.7.24環境,在開始本文之前要先在CentOS7裏面安裝Docker哦,我上篇已經講解如何在CentOS7下安裝Docker,如果還沒有在CentOS7安裝Docker的朋友可以參考我上篇文章。
文章地址在此,可以參考參考哦:Docker系列之Docker安裝

這裏再簡單的梳理下安裝步驟

Docker 要求 CentOS 系統的內核版本高於 3.10 ,查看本文的前提條件是要驗證下你的CentOS 版本是否支持 Docker。

通過 uname -r 命令查看你當前的內核版本

uname -r

我的 CentOS 系統的內核版本是高於 3.10 的uname -r 效果圖
初步安裝、啓動 Docker

yum update -y

yum -y install docker

systemctl start docker

設置 Docker 中國官方加速鏡像

使用 --registry-mirror 配置 Docker 守護進程
您可以配置 Docker 守護進程默認使用 Docker 官方鏡像加速。這樣您可以默認通過官方鏡像加速拉取鏡像,而無需在每次拉取時指定 registry.docker-cn.com。
您可以在 Docker 守護進程啓動時傳入 --registry-mirror 參數:

 docker --registry-mirror=https://registry.docker-cn.com daemon

爲了永久性保留更改,您可以修改 /etc/docker/daemon.json 文件並添加上 registry-mirrors 鍵值。

{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}

開放管理端口映射

vi /lib/systemd/system/docker.service

ExecStart=/usr/bin/dockerd ,替換爲:

ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -H tcp://0.0.0.0:7654

2375是管理端口,7654是備用端口

~/.bashrc中寫入 Docker 管理端口

export DOCKER_HOST=tcp://0.0.0.0:2375
source ~/.bashrc

修改保存後重啓 Docker 以使配置生效

systemctl daemon-reload
systemctl restart docker.service

測試Docker是否正常安裝和運行,這裏我這就不測試了

安裝好 Docker 後接下來安裝我們的 MySQL5.7.24

1、我們首先要先拉取鏡像,我這裏使用的是5.7.24版本,可根據你所需要的版本進行拉取

docker pull mysql:5.7.24

2、啓動容器,創建一個名爲mysql5_7_24的MySQL數據庫服務器容器實例

docker run --name mysql5_7_24 -p 33060:3306 -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7.24

參數命令說明:
-p 33060:3306:將容器的 3306 端口映射到主機的 33060 端口
-e MYSQL_ROOT_PASSWORD=root:初始化 root 用戶的密碼
-d 讓容器在後臺運行
-name 爲容器命名

訪問容器

docker exec -it mysql5_7_24 /bin/bash

-i 即使沒有附加也保持STDIN 打開
-t 分配一個僞終端
/bin/bash的作用是因爲Docker後臺必須運行一個進程,否則容器就會退出,在這裏表示啓動容器後啓動bash
進入了容器內部,我們就可以登錄到MySQL了
訪問容器
在容器中輸入mysql -uroot -p 輸入你的密碼,登錄到MySQL中
在這裏插入圖片描述
輸入 show databases; 查看數據庫
在這裏插入圖片描述
查看日誌

docker logs -f mysql5_7_24
[root@localhost ~]# docker logs -f mysql5_7_24
Initializing database
2019-01-24T18:45:27.997021Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-24T18:45:28.230900Z 0 [Warning] InnoDB: New log files created, LSN=45790
2019-01-24T18:45:28.340430Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2019-01-24T18:45:28.403676Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3811eb3a-2008-11e9-b320-0242ac110009.
2019-01-24T18:45:28.647202Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2019-01-24T18:45:28.648847Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
2019-01-24T18:45:29.593022Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593069Z 1 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593082Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593105Z 1 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593110Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593123Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593160Z 1 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:29.593169Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
Database initialized
Initializing certificates
Generating a RSA private key
.....................................+++++
..................................................................+++++
unable to write 'random state'
writing new private key to 'ca-key.pem'
-----
Generating a RSA private key
.................+++++
.............................................................................................................+++++
unable to write 'random state'
writing new private key to 'server-key.pem'
-----
Generating a RSA private key
..............................+++++
.....+++++
unable to write 'random state'
writing new private key to 'client-key.pem'
-----
Certificates initialized
MySQL init process in progress...
2019-01-24T18:45:32.965850Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-24T18:45:32.968059Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 91 ...
2019-01-24T18:45:32.971191Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-01-24T18:45:32.971232Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-24T18:45:32.971238Z 0 [Note] InnoDB: Uses event mutexes
2019-01-24T18:45:32.971242Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-24T18:45:32.971245Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-01-24T18:45:32.971248Z 0 [Note] InnoDB: Using Linux native AIO
2019-01-24T18:45:32.971536Z 0 [Note] InnoDB: Number of pools: 1
2019-01-24T18:45:32.971725Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-01-24T18:45:32.973700Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-01-24T18:45:32.982604Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-01-24T18:45:32.985549Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-01-24T18:45:32.997879Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-01-24T18:45:33.006191Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-01-24T18:45:33.006348Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-01-24T18:45:33.020122Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-01-24T18:45:33.022170Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-01-24T18:45:33.022217Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-01-24T18:45:33.024385Z 0 [Note] InnoDB: Waiting for purge to start
2019-01-24T18:45:33.075074Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 2591440
2019-01-24T18:45:33.075321Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-01-24T18:45:33.075618Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-01-24T18:45:33.076843Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190124 18:45:33
2019-01-24T18:45:33.082194Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2019-01-24T18:45:33.082556Z 0 [Warning] CA certificate ca.pem is self signed.
2019-01-24T18:45:33.086108Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-01-24T18:45:33.088740Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.088819Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.088829Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.088851Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.088856Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.088865Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.090281Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.090325Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:33.096208Z 0 [Note] Event Scheduler: Loaded 0 events
2019-01-24T18:45:33.096642Z 0 [Note] mysqld: ready for connections.
Version: '5.7.24'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
2019-01-24T18:45:35.976696Z 4 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976747Z 4 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976756Z 4 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976772Z 4 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976776Z 4 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976787Z 4 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976823Z 4 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:35.976859Z 4 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.

2019-01-24T18:45:35.979984Z 0 [Note] Giving 0 client threads a chance to die gracefully
2019-01-24T18:45:35.980019Z 0 [Note] Shutting down slave threads
2019-01-24T18:45:35.980028Z 0 [Note] Forcefully disconnecting 0 remaining clients
2019-01-24T18:45:35.980033Z 0 [Note] Event Scheduler: Purging the queue. 0 events
2019-01-24T18:45:35.980220Z 0 [Note] Binlog end
2019-01-24T18:45:35.980773Z 0 [Note] Shutting down plugin 'ngram'
2019-01-24T18:45:35.980811Z 0 [Note] Shutting down plugin 'partition'
2019-01-24T18:45:35.980817Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2019-01-24T18:45:35.980822Z 0 [Note] Shutting down plugin 'ARCHIVE'
2019-01-24T18:45:35.980824Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2019-01-24T18:45:35.980849Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2019-01-24T18:45:35.980856Z 0 [Note] Shutting down plugin 'MyISAM'
2019-01-24T18:45:35.980867Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2019-01-24T18:45:35.980893Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2019-01-24T18:45:35.980899Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2019-01-24T18:45:35.980903Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2019-01-24T18:45:35.980906Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2019-01-24T18:45:35.980909Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2019-01-24T18:45:35.980912Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2019-01-24T18:45:35.980915Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2019-01-24T18:45:35.980917Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2019-01-24T18:45:35.980920Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2019-01-24T18:45:35.980924Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2019-01-24T18:45:35.980927Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2019-01-24T18:45:35.980930Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2019-01-24T18:45:35.980933Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2019-01-24T18:45:35.980936Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2019-01-24T18:45:35.980939Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2019-01-24T18:45:35.980942Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2019-01-24T18:45:35.980946Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2019-01-24T18:45:35.980949Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2019-01-24T18:45:35.980952Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2019-01-24T18:45:35.980955Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2019-01-24T18:45:35.980959Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2019-01-24T18:45:35.980962Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2019-01-24T18:45:35.980966Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2019-01-24T18:45:35.980968Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2019-01-24T18:45:35.980971Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2019-01-24T18:45:35.980975Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2019-01-24T18:45:35.980978Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2019-01-24T18:45:35.980987Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2019-01-24T18:45:35.980991Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2019-01-24T18:45:35.980994Z 0 [Note] Shutting down plugin 'InnoDB'
2019-01-24T18:45:35.981115Z 0 [Note] InnoDB: FTS optimize thread exiting.
2019-01-24T18:45:35.981314Z 0 [Note] InnoDB: Starting shutdown...
2019-01-24T18:45:36.081796Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
2019-01-24T18:45:36.082361Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 190124 18:45:36
2019-01-24T18:45:37.438315Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12370782
2019-01-24T18:45:37.448535Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-01-24T18:45:37.448610Z 0 [Note] Shutting down plugin 'MEMORY'
2019-01-24T18:45:37.448630Z 0 [Note] Shutting down plugin 'CSV'
2019-01-24T18:45:37.448636Z 0 [Note] Shutting down plugin 'sha256_password'
2019-01-24T18:45:37.448639Z 0 [Note] Shutting down plugin 'mysql_native_password'
2019-01-24T18:45:37.448827Z 0 [Note] Shutting down plugin 'binlog'
2019-01-24T18:45:37.449467Z 0 [Note] mysqld: Shutdown complete


MySQL init process done. Ready for start up.

2019-01-24T18:45:37.736726Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-24T18:45:37.738416Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 1 ...
2019-01-24T18:45:37.741635Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-01-24T18:45:37.741723Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-24T18:45:37.741729Z 0 [Note] InnoDB: Uses event mutexes
2019-01-24T18:45:37.741734Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-24T18:45:37.741736Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-01-24T18:45:37.741739Z 0 [Note] InnoDB: Using Linux native AIO
2019-01-24T18:45:37.742042Z 0 [Note] InnoDB: Number of pools: 1
2019-01-24T18:45:37.742218Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-01-24T18:45:37.744018Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-01-24T18:45:37.754703Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-01-24T18:45:37.757312Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-01-24T18:45:37.769641Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-01-24T18:45:37.777797Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-01-24T18:45:37.777974Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-01-24T18:45:37.790200Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-01-24T18:45:37.790888Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-01-24T18:45:37.790914Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-01-24T18:45:37.791831Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 12370782
2019-01-24T18:45:37.792222Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-01-24T18:45:37.792499Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-01-24T18:45:37.795173Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190124 18:45:37
2019-01-24T18:45:37.797242Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2019-01-24T18:45:37.797531Z 0 [Warning] CA certificate ca.pem is self signed.
2019-01-24T18:45:37.799702Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-01-24T18:45:37.800479Z 0 [Note] IPv6 is available.
2019-01-24T18:45:37.800526Z 0 [Note]   - '::' resolves to '::';
2019-01-24T18:45:37.800550Z 0 [Note] Server socket created on IP: '::'.
2019-01-24T18:45:37.802496Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-01-24T18:45:37.804137Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.804196Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.804204Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.804227Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.804230Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.804240Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.806114Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.806157Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T18:45:37.813131Z 0 [Note] Event Scheduler: Loaded 0 events
2019-01-24T18:45:37.813655Z 0 [Note] mysqld: ready for connections.
Version: '5.7.24'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
2019-01-24T21:36:05.105814Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-01-24T21:36:05.140744Z 0 [Note] mysqld (mysqld 5.7.24) starting as process 1 ...
2019-01-24T21:36:05.167362Z 0 [Note] InnoDB: PUNCH HOLE support available
2019-01-24T21:36:05.167516Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-01-24T21:36:05.167529Z 0 [Note] InnoDB: Uses event mutexes
2019-01-24T21:36:05.167539Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2019-01-24T21:36:05.167546Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-01-24T21:36:05.167552Z 0 [Note] InnoDB: Using Linux native AIO
2019-01-24T21:36:05.170570Z 0 [Note] InnoDB: Number of pools: 1
2019-01-24T21:36:05.213041Z 0 [Note] InnoDB: Using CPU crc32 instructions
2019-01-24T21:36:05.252672Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2019-01-24T21:36:05.465169Z 0 [Note] InnoDB: Completed initialization of buffer pool
2019-01-24T21:36:05.489769Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2019-01-24T21:36:05.630189Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2019-01-24T21:36:05.693901Z 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 12370801
2019-01-24T21:36:05.693989Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 12370810
2019-01-24T21:36:05.694012Z 0 [Note] InnoDB: Database was not shutdown normally!
2019-01-24T21:36:05.694024Z 0 [Note] InnoDB: Starting crash recovery.
2019-01-24T21:36:06.079604Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2019-01-24T21:36:06.079654Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2019-01-24T21:36:06.079809Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2019-01-24T21:36:06.193687Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2019-01-24T21:36:06.205138Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2019-01-24T21:36:06.205178Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2019-01-24T21:36:06.216538Z 0 [Note] InnoDB: Waiting for purge to start
2019-01-24T21:36:06.267332Z 0 [Note] InnoDB: 5.7.24 started; log sequence number 12370810
2019-01-24T21:36:06.267733Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2019-01-24T21:36:06.268007Z 0 [Note] Plugin 'FEDERATED' is disabled.
2019-01-24T21:36:06.428971Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2019-01-24T21:36:06.443955Z 0 [Note] InnoDB: Buffer pool(s) load completed at 190124 21:36:06
2019-01-24T21:36:06.466124Z 0 [Warning] CA certificate ca.pem is self signed.
2019-01-24T21:36:06.473432Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
2019-01-24T21:36:06.474844Z 0 [Note] IPv6 is available.
2019-01-24T21:36:06.474966Z 0 [Note]   - '::' resolves to '::';
2019-01-24T21:36:06.475035Z 0 [Note] Server socket created on IP: '::'.
2019-01-24T21:36:06.527839Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2019-01-24T21:36:06.602274Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.602467Z 0 [Warning] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.602501Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.603408Z 0 [Warning] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.603556Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.604453Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.691958Z 0 [Warning] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.692132Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
2019-01-24T21:36:06.835839Z 0 [Note] Event Scheduler: Loaded 0 events
2019-01-24T21:36:06.836575Z 0 [Note] mysqld: ready for connections.
Version: '5.7.24'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

到這一步MySQL5.7.24就安裝好並啓動起來了,下面我們用 Navicat Premium 連接這個 MySQL5.7.24 並導入SQL。
首先輸入 ip addre 查看主機的IP

[root@localhost ~]# ip addre
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:28:3c:36 brd ff:ff:ff:ff:ff:ff
    inet 192.168.149.133/24 brd 192.168.149.255 scope global noprefixroute dynamic ens33
       valid_lft 929sec preferred_lft 929sec
    inet6 fe80::e147:9574:ea82:63d0/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:73:1c:1b brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:73:1c:1b brd ff:ff:ff:ff:ff:ff
5: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:c3:8d:61:45 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:c3ff:fe8d:6145/64 scope link 
       valid_lft forever preferred_lft forever
7: vetha5edc23@if6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether de:cf:d2:49:6e:18 brd ff:ff:ff:ff:ff:ff link-netnsid 3
    inet6 fe80::dccf:d2ff:fe49:6e18/64 scope link 
       valid_lft forever preferred_lft forever
9: veth899bf94@if8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 02:00:46:2c:7e:f3 brd ff:ff:ff:ff:ff:ff link-netnsid 2
    inet6 fe80::46ff:fe2c:7ef3/64 scope link 
       valid_lft forever preferred_lft forever
11: vethc5ec3b5@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 8e:c7:aa:47:db:dc brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::8cc7:aaff:fe47:dbdc/64 scope link 
       valid_lft forever preferred_lft forever
13: veth0c29d70@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 2a:c5:fa:e8:42:f0 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::28c5:faff:fee8:42f0/64 scope link 
       valid_lft forever preferred_lft forever
15: veth25574f3@if14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether ca:15:c6:cd:8c:98 brd ff:ff:ff:ff:ff:ff link-netnsid 4
    inet6 fe80::c815:c6ff:fecd:8c98/64 scope link 
       valid_lft forever preferred_lft forever
17: vethc77db91@if16: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether 46:72:3f:08:81:77 brd ff:ff:ff:ff:ff:ff link-netnsid 5
    inet6 fe80::4472:3fff:fe08:8177/64 scope link 
       valid_lft forever preferred_lft forever
19: veth6cf6640@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether be:a9:cd:d7:38:aa brd ff:ff:ff:ff:ff:ff link-netnsid 6
    inet6 fe80::bca9:cdff:fed7:38aa/64 scope link 
       valid_lft forever preferred_lft forever
21: vethdb1a983@if20: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether ae:be:b7:65:25:66 brd ff:ff:ff:ff:ff:ff link-netnsid 7
    inet6 fe80::acbe:b7ff:fe65:2566/64 scope link 
       valid_lft forever preferred_lft forever
[root@localhost ~]# 

在這裏插入圖片描述
然後打開 Navicat Premium
在這裏插入圖片描述
然後輸入主機的IP:192.168.149.133,啓動容器映射的端口號33060,還有你的用戶名和密碼,都是設置的root。
在這裏插入圖片描述
查看容器的狀態和映射的端口號等相關信息可輸入docker ps查看
在這裏插入圖片描述
連接成功後
在這裏插入圖片描述
我們就可以創建我們項目所需要的數據庫和表,導入我們需要導入的SQL了。

好咯,Docker安裝MySQL5.7.24就到此告一段落了,更多精彩,請看下回分解。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章