Home  >  Article  >  Database  >  How to install MySql8 with Docker and access it remotely

How to install MySql8 with Docker and access it remotely

WBOY
WBOYforward
2023-05-26 18:55:061518browse

Pull mysql image

Use the command to pull mysql. The last version currently is 8.0.2*

docker pull mysql

How to install MySql8 with Docker and access it remotely

It can also be viewed on dockerhub Download the specified version.

How to install MySql8 with Docker and access it remotely

Start mysql8

docker run --name mysql01 -p 3333:3306 -e MYSQL_ROOT_PASSWORD=123654 mysql:latest
docker ps //查看运行的容器
docker exec -it mysql01 /bin/bash //进入控制台

Start mysql:

  • -it:-i->In interactive mode Run the container, -t-> reassign a pseudo input terminal to the container. Generally, these two are used together.

  • -p 3333:3306 The default 3306 is not used. It is changed to the mysql3306

  • –name bit of the host's 3333 mapping container. To give a name to the container, you need mysql01

  • -e to configure the application in the container. A password is set here

  • /bin/bash after startup Enter the console of the container

How to install MySql8 with Docker and access it remotely

##This will enter the console of the container

Configure mysql

First Log in to mysql

mysql -u root -p //然后输入密码

Check the version of mysql

status;

How to install MySql8 with Docker and access it remotely

for authorized remote connection (note that mysql 8.0 is different from the previous authorization method)

GRANT ALL ON *.* TO 'root'@'%';//远程连接
flush privileges; //刷新权限
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;//更改加密规则
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123654';//设置密码
flush privileges;//刷新权限

How to install MySql8 with Docker and access it remotely

Remote connection test

Using DBeaver, the new connection is to install the mysql8 driver

How to install MySql8 with Docker and access it remotely

The above is the detailed content of How to install MySql8 with Docker and access it remotely. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete