Last active
October 30, 2018 08:53
-
-
Save asalimonov/a302697c5b6ebd2f76c23df9536196ac to your computer and use it in GitHub Desktop.
MySQL in Docker Container
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
#remove mysql images | |
docker image ls | grep mysql | cut -f 1 -d ' ' | xargs docker image rm -f | |
#setup docker container | |
docker run --name mysql0 -p 0.0.0.0:3306:3306 -p 0.0.0.0:33060:33060 -td mysql/mysql-server:8.0 | |
#get generated password | |
docker logs mysql0 2>&1 | grep GENERATED | |
#update root's password | |
docker exec -it mysql0 mysql -uroot -p | |
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; | |
#create users | |
CREATE USER 'monty'@'localhost' IDENTIFIED BY 'password'; | |
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost' WITH GRANT OPTION; | |
CREATE USER 'monty'@'%' IDENTIFIED BY 'password'; | |
GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%' WITH GRANT OPTION; | |
CREATE USER 'admin'@'localhost'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment