Home > Database > Mysql Tutorial > body text

How to install MySql8 with Docker and access it remotely

WBOY
Release: 2023-05-26 18:55:06
forward
1520 people have browsed it

Pull mysql image

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

docker pull mysql
Copy after login

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 //进入控制台
Copy after login

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 //然后输入密码
Copy after login

Check the version of mysql

status;
Copy after login

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;//刷新权限
Copy after login

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!

Related labels:
source:yisu.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template