Deploy the MySQL method using docker-compose
This article mainly introduces the use of docker-compose deployment MySQL method, the content of the article is carefully selected and edited by the author, with a certain pertinence, for everyone's reference significance is still relatively great, the following with the author to understand the use of docker-compose deployment MySQL method.
[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: alwaysports:-"3306 purl 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.05000/tcp registry 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 >
After reading the above about using docker-compose to deploy MySQL method, many readers must have some understanding. If you need to get more industry knowledge and information, you can continue to follow our industry information column.