How to set remote access permissions in MySQL 8.0

How to set remote access permissions in MySQL 8.0

The previous article explained how to reset the MySQL password. Some students reported that they could not connect to the database. This is because MySQL only supports localhost access after installation. We must set it up before we can access it remotely. In addition, there are some problems when connecting to MySQL 8.0. This article will also explain how to solve them.

1. Log in to MySQL

mysql -u root -p

Enter your password

2. Select MySQL database

use mysql;

Because the user table in the mysql database stores user information.

3. View the relevant information of the current root user in the user table of the mysql database

select host, user, authentication_string, plugin from user; 

After executing the above command, a table will be displayed

Check the host of the root user in the table. By default, it should show localhost, which only supports local access and does not allow remote access.

4. Authorize all permissions of the root user and set up remote access

GRANT ALL ON *.* TO 'root'@'%';

GRANT ALL ON means all permissions, and % means all hosts are wildcarded, allowing remote access.

5. Refresh permissions

After all operations, you should execute

flush privileges;

6. Check the host of the root user

Execute step 2 again, and you will find that the host of the root user has become %, which means that our modification has been successful and can be accessed remotely.

7. Access the database

There are many visualization tools for remote access to databases, such as Navicat, SQLyog, MySQL workbench, etc. I use Navicat here.

Enter the access host and password, and error 2059 will be reported. This is because the encryption rules of MySql 8.0 and 5.0 are different, and the current visualization tool only supports the old encryption method.

There are two ways to solve this problem. One is to update the Navicat driver to solve this problem, and the other is to change the encryption rule of MySQL user login to mysql_native_password. I tried the first method and it didn't work, so I'll use the second method here.

8. Modify encryption rules

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; 

password is your current password.

9. Update the root user password

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password'; 

password is the new password you set.

10. Refresh permissions

FLUSH PRIVILEGES;

OK, the settings are complete, use Navicat to connect to the database again

This is the end of this article about how to set remote access permissions for MySQL 8.0. For more information about remote access permissions for MySQL 8.0, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • A brief discussion on MySQL user permission table
  • Implementation of Mysql User Rights Management
  • Detailed explanation of MySQL user rights management
  • MySQL permission control details analysis
  • MySQL permission control detailed explanation
  • Detailed tutorial on how to create a user in mysql and grant user permissions
  • Mysql modify stored procedure related permissions issue
  • MySQL permissions and database design case study

<<:  A simple way to achieve scrolling effect with HTML tag marquee (must read)

>>:  Basic tutorial on controlling Turtlebot3 mobile robot with ROS

Recommend

An article to give you a deep understanding of Mysql triggers

Table of contents 1. When inserting or modifying ...

JavaScript implements circular progress bar effect

This article example shares the specific code of ...

Example of how to adapt the Vue project to the large screen

A brief analysis of rem First of all, rem is a CS...

Solution to MySQL 8.0 cannot start 3534

MySQL 8.0 service cannot be started Recently enco...

Docker port mapping and external inaccessibility issues

The Docker container provides services and listen...

jQuery achieves large-screen scrolling playback effect

This article shares the specific code of jQuery t...

React example of how to get the value of the input box

React multiple ways to get the value of the input...

Detailed tutorial for installing mysql5.7.21 under Windows

This article shares the installation tutorial of ...

Use jQuery to fix the invalid page anchor point problem under iframe

The application scenario is: the iframe page has n...

Detailed explanation of object literals in JS

Table of contents Preface 1. Set the prototype on...

The use of vue directive v-bind and points to note

Table of contents 1. v-bind: can bind some data t...

How to create a view in MySQL

Basic syntax You can create a view using the CREA...