How to allow external network access to mysql and modify mysql account password

How to allow external network access to mysql and modify mysql account password

The root account of mysql, I usually use localhost or 127.0.0.1 when connecting. The mysql on the company's test server is also localhost, so I can't access it when I want to, and the test is suspended.

The solution is as follows:

1. Modify the table, log in to the MySQL database, switch to the MySQL database, and use the SQL statement to view "select host, user from user;"

mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;
mysql>flush privileges;

Note: The last sentence is very important to make the changes take effect. If it is not written, remote connection will still not be possible.

2. Authorize the user, you want to connect to the mysql server from any host using the root password

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin123' WITH GRANT OPTION;
flush privileges;

If you want to allow user root to connect to the mysql server from the host with ip 192.168.1.104

GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104' IDENTIFIED BY 'admin123' WITH GRANT OPTION;
flush privileges;

Change MySql Password

In MySQL 5.7 the password field has been removed from the mysql.user table and the new field is called "authentication_string".

Select the database:

use mysql;

Update the root password:

update user set authentication_string=password('new password') where user='root' and Host='localhost';

Refresh permissions:

flush privileges;

I hope the above content can help everyone. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • How to modify the root account password in MySQL
  • MySQL account password modification method (summary)

<<:  A very detailed summary of communication between Vue components

>>:  Implementation of nginx worker process loop

Recommend

HTML+CSS+JS realizes the scrolling gradient effect of the navigation bar

Table of contents First look at the effect: accom...

How to write beautiful HTML code

What Beautiful HTML Code Looks Like How to write ...

Analysis of the causes of accidents caused by Unicode signature BOM

Maybe you are using include files here, which is u...

How to disable ads in the terminal welcome message in Ubuntu Server

If you are using the latest Ubuntu Server version...

JS implements circular progress bar drag and slide

This article example shares the specific code of ...

Implementation code of jquery step progress axis plug-in

A jQuery plugin every day - step progress axis st...

User experience analysis of facebook dating website design

<br />Related article: Analysis of Facebook&...

How to compile the Linux kernel

1. Download the required kernel version 2. Upload...

Summary of MySQL database and table sharding

During project development, our database data is ...

JavaScript implements asynchronous submission of form data

This article example shares the specific code of ...

Understanding MySQL Locking Based on Update SQL Statements

Preface MySQL database lock is an important means...

Super detailed basic JavaScript syntax rules

Table of contents 01 JavaScript (abbreviated as: ...