Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.17 KB

File metadata and controls

41 lines (28 loc) · 1.17 KB

ReadMe_static

Mac

hub.docker.com » starting mysql locally

Start the MySQL database locally with the following command:

Start the MySQL database in ephemeral mode

# Start the MySQL database locally, in ephemeral mode
docker run --rm -it --name mysql_lts -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -d mysql:lts
# Execute a bash shell in the container
docker exec -it mysql_lts bash

Start the MySQL database in persistent mode

# Start the MySQL database locally in persistent mode
docker run --name mysql_lts -p 3306:3306 -e MYSQL_ROOT_PASSWORD=secret -v $(pwd)/mysql_data:/var/lib/mysql -d mysql:lts

# Execute a bash shell in the container
docker exec -it mysql_lts bash

Connect to the MySQL database

# Connect to the MySQL database in the container
mysql -hlocalhost -uroot -psecret