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
Release: 2023-06-02 22:07:33
forward
1448 people have browsed it

Step 1: Download the mysql mirror

docker pull mysql
Copy after login

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

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

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

Step 5: Log in to mysql

mysql -u root -p
Copy after login

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

Change remote link authorization

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

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

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

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!

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