Setup mysql with docker
The docker compose file I use:
1 | version: '3' |
Access into the docker container
docker exec -it <container id> bash
The container id can be find by docker ps
Create new database
mysql -u root -p
CREATE DATABASE 'newdatabase';
1 | CREATE USER 'dev'@'localhost' IDENTIFIED BY 'mypw'; |
flush privileges;
CREATE USER 'newuser'@'%' IDENTIFIED BY 'newpassword';
Then give the new account “newuser” permission to read and write the new database
GRANT ALL PRIVILEGES ON newdatabase.* TO 'newuser'@'localhost';
quit the root login and switch to the user
quit
mysql -u <newuser> -p
Setup mysql with docker