使用docker-compose部署MySQL方法
admin
2023-04-17 07:21:29
0

文主要给大家介绍使用docker-compose部署MySQL方法,文章内容都是笔者用心摘选和编辑的,具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起了解下使用docker-compose部署MySQL方法吧。 

[root@169_test mariadb10.3]# cat docker-compose.yml
version: '2'

services:
db:
image: mytest/mariadb10.3:latest
volumes:

  - ./db_data/:/var/lib/mysql/
restart: always
ports:
  - "3306:3306"

[root@169_test mariadb10.3]# docker-compose up
Creating network "mariadb103_default" with the default driver
Creating mariadb103_db_1 ... done
Attaching to mariadb103_db_1
db_1  | Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
db_1  | OK
db_1  |
db_1  | To start mysqld at boot time you have to copy
db_1  | support-files/mysql.server to the right place for your system
db_1  |
db_1  |
db_1  | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
db_1  | To do so, start the server, then issue the following commands:
db_1  |
db_1  | '/usr/bin/mysqladmin' -u root password 'new-password'
db_1  | '/usr/bin/mysqladmin' -u root -h d56fe1b27eb9 password 'new-password'
db_1  |
db_1  | Alternatively you can run:
db_1  | '/usr/bin/mysql_secure_installation'
db_1  |
db_1  | which will also give you the option of removing the test
db_1  | databases and anonymous user created by default.  This is
db_1  | strongly recommended for production servers.
db_1  |
db_1  | See the MariaDB Knowledgebase at http://mariadb.com/kb or the
db_1  | MySQL manual for more instructions.
db_1  |
db_1  | You can start the MariaDB daemon with:
db_1  | cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'
db_1  |
db_1  | You can test the MariaDB daemon with mysql-test-run.pl
db_1  | cd '/usr/mysql-test' ; perl mysql-test-run.pl
db_1  |
db_1  | Please report any problems at http://mariadb.org/jira
db_1  |
db_1  | The latest information about MariaDB is available at http://mariadb.org/.
db_1  | You can find additional information about the MySQL part at:
db_1  | http://dev.mysql.com
db_1  | Consider joining MariaDB's strong and vibrant community:
db_1  | https://mariadb.org/get-involved/
db_1  |
db_1  | Starting MariaDB.190611 03:38:08 mysqld_safe Logging to '/var/lib/mysql/d56fe1b27eb9.err'.
db_1  | 190611 03:38:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
db_1  |  SUCCESS!

^CGracefully stopping... (press Ctrl+C again to force)
Stopping mariadb103_db_1 ...
Killing mariadb103_db_1 ... done
[root@169_test mariadb10.3]# ^C
[root@169_test mariadb10.3]# docker ps -a
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                       PORTS                    NAMES
d56fe1b27eb9        mytest/mariadb10.3:latest   "/run.sh"                27 seconds ago      Exited (137) 7 seconds ago                            mariadb103_db_1
762ed1f53368        registry:2                  "/entrypoint.sh /etc…"   2 hours ago         Up 2 hours                   0.0.0.0:5000->5000/tcp   registry
[root@169_test mariadb10.3]# docker rm d
d
[root@169_test mariadb10.3]# docker-compose up  -d
Creating mariadb103_db_1 ... done

[root@169_test mariadb10.3]# mysql  -h227.0.0.1 -uroot -P3306 -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 14
Server version: 5.5.5-10.3.15-MariaDB MariaDB Server

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> select @@version;
+-----------------+
| @@version       |
+-----------------+
| 10.3.15-MariaDB |
+-----------------+
1 row in set (0.00 sec)

mysql>

看完以上关于使用docker-compose部署MySQL方法,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。

相关内容

热门资讯

今日重磅消息“欢乐众娱到底是不... 网上科普关于“欢乐众娱有没有挂”话题很是火热,小编也是针对欢乐众娱作*弊开挂的方法以及开挂对应的知识...
玩家攻略科普“皇豪众娱牛牛真的... 网上科普关于“皇豪众娱牛牛有没有挂”话题很是火热,小编也是针对皇豪众娱牛牛作*弊开挂的方法以及开挂对...
【第一财经】“宝宝浙江游戏怎么... 家人们!今天小编来为大家解答宝宝浙江游戏透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里...
重磅消息“天府红桃3怎么装挂?... 重磅消息“天府红桃3怎么装挂?”(透视曝光猫腻)您好,天府红桃3这个游戏其实有挂的,确实是有挂的,需...
【今日要闻】“微壳字牌究竟有挂... 有 亲,根据资深记者爆料微壳字牌是可以开挂的,确实有挂(咨询软件无需打开...
终于明白“相约福建麻将可以开挂... 终于明白“相约福建麻将可以开挂吗?”(确实真的有挂)您好,相约福建麻将这个游戏其实有挂的,确实是有挂...
【今日要闻】“土豪赢三张怎么开... 网上科普关于“土豪赢三张有没有挂”话题很是火热,小编也是针对土豪赢三张作*弊开挂的方法以及开挂对应的...
终于明白“暗宝到底是不是挂?”... 有 亲,根据资深记者爆料暗宝是可以开挂的,确实有挂(咨询软件无需打开直接...
今日重大消息“哥哥打大A开挂器... 您好:哥哥打大A这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9784099】很多玩家在这款游...
终于明白“麻友圈2挪来挪去怎么... 网上科普关于“麻友圈2挪来挪去有没有挂”话题很是火热,小编也是针对麻友圈2挪来挪去作*弊开挂的方法以...