2020年9月9日星期三

Introduction of Docker mysql container


1. Create a network for MySQL, and run MySQL

$ docker network create mysql-net 

$ docker run -d \
    --network mysql-net --network-alias mysql \
    -v mysql-data:/var/lib/mysql \
    -e MYSQL_ROOT_PASSWORD=secret \
    -e MYSQL_DATABASE=mysql \
    mysql:5   

docker exec -it a09 mysql -p
Enter password: secret
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.31 MySQL Community Server (GPL)
...
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> show databases
    -> ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 





没有评论: