Home > Database > Mysql Tutorial > body text

Running MySQL Server in Docker

Susan Sarandon
Release: 2024-10-24 00:51:29
Original
125 people have browsed it

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';

Copy after login

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;
Copy after login

Now Connect Using Workbench

host = localhost

port = 3306

user_name = user

user_password = password
Copy after login

The above is the detailed content of Running MySQL Server in Docker. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!