How to enable remote access permissions in MYSQL

How to enable remote access permissions in MYSQL

1. Log in to MySQL database

mysql -u root -p

View the user table

mysql> use mysql;
Database changed
mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
+--------------+------+-------------------------------------------+
2 rows in set (0.00 sec)

You can see the root user that has been created in the user table. The host field indicates the host being logged in. Its value can be either IP or host name.

(1) If you want to log in using your local IP address, you can change the Host value to your own IP address.

2. Realize remote connection (authorization method)

Changing the value of the host field to % means that you can log in to the MySQL server as the root user on any client machine. It is recommended to set it to % during development.
update user set host = '%' where user = 'root';

Change the permissions to ALL PRIVILEGES

mysql> use mysql;
Database changed
mysql> grant all privileges on *.* to root@'%' identified by "password";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> select host,user,password from user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| localhost | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| 192.168.1.1 | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
| % | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
+--------------+------+-------------------------------------------+
3 rows in set (0.00 sec)

This way the machine can remotely access MySql on the machine with the username root and password root.

3. Realize remote connection (table modification method)

use mysql;

update user set host = '%' where user = 'root';

In this way, you can access MySQL remotely through the root user. If you have any additions, please contact the editor of 123WORDPRESS.COM.

You may also be interested in:
  • 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
  • How to set remote access permissions in MySQL 8.0
  • How to use DCL to manage users and control permissions in MySQL
  • How to create users and manage permissions in MySQL
  • Example analysis of mysql user rights management
  • Summary of methods for querying MySQL user permissions
  • The easiest way to create a new user and grant permissions to MySQL
  • Detailed explanation of MySQL user and permission management
  • MySQL permission control details analysis

<<:  How to install Android x86 in vmware virtual machine

>>:  JavaScript style object and CurrentStyle object case study

Recommend

How to deploy Rancher with Docker (no pitfalls)

Must read before operation: Note: If you want to ...

Quickly learn MySQL basics

Table of contents Understanding SQL Understanding...

Web Design Summary

<br />From the birth of my first personal pa...

Handtrack.js library for real-time monitoring of hand movements (recommended)

【Introduction】: Handtrack.js is a prototype libra...

The docker-maven-plugin plugin cannot pull the corresponding jar package

When using the docker-maven-plugin plug-in, Maven...

Detailed explanation of React event binding

1. What is In react applications, event names are...

MySQL knowledge points for the second-level computer exam mysql alter command

Usage of alter command in mysql to edit table str...

CSS and HTML and front-end technology layer diagram

The relationship between Javascript and DOM is ve...

JavaScript to achieve a simple magnifying glass effect

There is a picture in a big box. When you put the...

In-depth explanation of MySQL learning engine, explain and permissions

engine Introduction Innodb engine The Innodb engi...

How to find slow SQL statements in MySQL

How to find slow SQL statements in MySQL? This ma...

Introduction and usage examples of ref and $refs in Vue

Preface In JavaScript, you need to use document.q...

How to dynamically modify the replication filter in mysql

MySQL dynamically modify replication filters Let ...

MySQL 5.7.17 installation and use graphic tutorial

MySQL is a relational database management system ...