Last active
June 1, 2023 13:07
-
-
Save zeitounator/2840c70e0684aae3be1e2aca4d69089e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: all names prefixed with `my_` to prevent | |
# any conflicts on my local machine | |
$ docker volume create my_mysql | |
my_mysql | |
$ docker volume create my_mysql_config | |
my_mysql_config | |
$ docker network create my_mysqlnet | |
ede4f309c2f6eeace62a286dee849da0bbc3bd9d98c9071af0eebe4931342bfe | |
$ docker run --rm -d -v my_mysql:/var/lib/mysql \ | |
> -v my_mysql_config:/etc/mysql \ | |
> -p 6306:3306 --network my_mysqlnet \ | |
> --name my_mysqldb \ | |
> -e MYSQL_ROOT_PASSWORD=p@ssword1 \ | |
> mysql | |
Unable to find image 'mysql:latest' locally | |
latest: Pulling from library/mysql | |
90e2fb2facff: Pull complete | |
ba60eb20fd5f: Pull complete | |
4f509402d469: Pull complete | |
496c2cfa6815: Pull complete | |
8ec1dfa9522c: Pull complete | |
6dec7ba896f8: Pull complete | |
dc9ff75362b0: Pull complete | |
73e4682f9014: Pull complete | |
9ffdeecd6fb6: Pull complete | |
a4346ccfb53f: Pull complete | |
434c13bc32de: Pull complete | |
Digest: sha256:d6164ff4855b9b3f2c7748c6ec564ccff841f79a7023db0f9293143481a44b6e | |
Status: Downloaded newer image for mysql:latest | |
23be10bed889972cd29240473ce6abe0c3e617fb2a11988cfb4850c033f53e30 | |
$ docker exec -it my_mysqldb mysql -u root -p | |
Enter password: | |
Welcome to the MySQL monitor. Commands end with ; or \g. | |
Your MySQL connection id is 8 | |
Server version: 8.0.33 MySQL Community Server - GPL | |
Copyright (c) 2000, 2023, Oracle and/or its affiliates. | |
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> show databases; | |
+--------------------+ | |
| Database | | |
+--------------------+ | |
| information_schema | | |
| mysql | | |
| performance_schema | | |
| sys | | |
+--------------------+ | |
4 rows in set (0.00 sec) | |
mysql> exit | |
Bye | |
$ docker stop my_mysqldb | |
my_mysqldb | |
$ docker network rm my_mysqlnet | |
my_mysqlnet | |
$ docker volume rm my_mysql my_mysql_config | |
my_mysql | |
my_mysql_config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment