Home >Database >Mysql Tutorial >How to install mysql8 and configure remote connection with docker under Linux

How to install mysql8 and configure remote connection with docker under Linux

WBOY
WBOYforward
2023-06-02 22:07:331447browse

Step 1: Download the mysql mirror

docker pull mysql

The default is to download the latest stable version

Step 2: Start the mysql mirror

docker run --name dockermysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mysqlpassword -d mysql
  • --name is the alias of the image

  • -p maps 3306 to 3306 (docker is a virtual machine with its own port)

  • -e MYSQL_ROOT_PASSWORD=mysqlpassword Set the mysql server password (required later, be sure to remember)

  • -d Backend startup

  • Start the mirror name (can Replace with id)

The third step: Query the started image

docker ps

is as follows:

How to install mysql8 and configure remote connection with docker under Linux

The fourth step Step: Enter the container

docker exec -it dockermysql bash

dockermysql is the name of the image, you can use id instead

Step 5: Log in to mysql

mysql -u root -p

and enter the password set above

Step 6: Set up remote access

Switch database (the default should be this, it’s okay not to switch, just switch it to be on the safe side)

use mysql;

Change remote link authorization

grant all privileges on *.* to 'root'@'%';

Step 7: Navicat Link Times 2059 Error

The reason for the error is a problem with the encryption method

Check it:

select Host,User,plugin from user;

The result before modification is as follows:

How to install mysql8 and configure remote connection with docker under Linux

Execute the modification command:

alter user 'root'@'%' identified with mysql_native_password by 'yourPassword';

Change it to your mysql password

The result after successful modification is as follows:

How to install mysql8 and configure remote connection with docker under Linux

The above is the detailed content of How to install mysql8 and configure remote connection with docker under Linux. 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