Last active
August 23, 2021 22:58
-
-
Save NovemberDev/5ce1bbc6c13662ccecaacdb9694bcb90 to your computer and use it in GitHub Desktop.
Run a mysql really quick in a docker container (cmd)
This file contains hidden or 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
docker network create -d bridge internal-network | |
docker pull mysql | |
docker run --network=internal-network -p 3306:3306 --name mysql-db -e MYSQL_ROOT_PASSWORD=root -e MYSQL_ROOT_HOST=% -d mysql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you compose your other containers with this option in the docker-compose.override.yml or docker-compose.yml file:
Your connection string from within another docker container (which accesses the db from this new container) will be:
"Server=host.docker.internal;Port=3306;Database=mysql-db;Uid=root;Pwd=root;"
Your connection string from "outside" aka the host machine (with MySql Workbench) will be:
"Server=127.0.0.1;Port=3306;Database=mysql-db;Uid=root;Pwd=root;"
You can use MySql Workbench from your host machine to inspect your db or use a shell to create a new database:
mysql -p
create database mysql-db;