DEV Community

Abhijeet Gavali
Abhijeet Gavali

Posted on

Running MySQL Server in Docker

no theory

Check docker if installed

docker version

Download MySQL server image

docker pull mysql/mysql-server

Run MySQL Server container

docker run --name='sql_container' -d -p 3306:3306 mysql/mysql-server

Check Logs and copy root password generated by MySQL Server

docker logs sql_container

Go in bash and update the root password to simple password

docker exec -it sql_container bash

cd /var/lib/mysql

mysql -u root -p

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

Enter fullscreen mode Exit fullscreen mode

Create new user for accessing db \ Root access not recomendade

CREATE USER 'user'@'%' IDENTIFIED BY 'passwod';

GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;
Enter fullscreen mode Exit fullscreen mode

Now Connect Using Workbench

host = localhost

port = 3306

user_name = user

user_password = password
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more