Skip to content

Instantly share code, notes, and snippets.

@spdeepak
Last active August 2, 2018 13:56
Show Gist options
  • Save spdeepak/260058370efa52585306f942b9d8564f to your computer and use it in GitHub Desktop.
Save spdeepak/260058370efa52585306f942b9d8564f to your computer and use it in GitHub Desktop.
Run MySQL using Docker
#Start MySQL
#MYSQL_ROOT_PASSWORD - for root password
#MYSQL_DATABASE - for a startup database
#MYSQL_USER, MYSQL_PASSWORD - Now you now what this parameter might be
#For more stuff read this page -> https://hub.docker.com/_/mysql/
#1. Start MySQL with a root password, the root admin username will be root
docker run --name mysql1 -e MYSQL_ROOT_PASSWORD=root -d mysql:latest
#2. Start MySQL without a password. But read the logs to see the password
docker run --name mysql1 mysql:latest
#3. To see the logs of MySQL start
docker logs mysql1
#4. Open MySQL console started by Docker
docker exec -it mysql1 mysql -u root -p
#5. Stop the MySQL container
docker container ls -la
docker stop _containerID_
#6. List of all containers
docker ps -a
#7. Start the stopped container
docker start -ai mysql1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment