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

Blog    

Recommend

Introduction to the use of html base tag target=_parent

The <base> tag specifies the default address...

W3C Tutorial (7): W3C XSL Activities

A style sheet describes how a document should be ...

dl, dt, dd list label examples

The dd and dt tags are used for lists. We usually...

JavaScript to achieve click image flip effect

I was recently working on a project about face co...

How to use vuex in Vue project

Table of contents What is Vuex? Vuex usage cycle ...

Specific use of Mysql prepare preprocessing

Table of contents 1. Preprocessing 2. Pretreatmen...

Element table header row height problem solution

Table of contents Preface 1. Cause of the problem...

Vue implements a search box with a magnifying glass

This article shares with you how to use Vue to im...

Detailed explanation of the use of MySQL sql_mode

Table of contents Preface sql_mode explained The ...

How to solve "Unable to start mysql service error 1069"

Today, when I was on the road, a colleague sent m...

WeChat applet to determine whether the mobile phone number is legal example code

Table of contents Scenario Effect Code Summarize ...

In-depth explanation of binlog in MySQL 8.0

1 Introduction Binary log records SQL statements ...

How to convert JavaScript array into tree structure

1. Demand The backend provides such data for the ...

HTML table markup tutorial (43): VALIGN attribute of the table header

In the vertical direction, you can set the alignm...

Install CentOS 7 on VMware14 Graphic Tutorial

Introduction to CentOS CentOS is an enterprise-cl...