Home > Database > Mysql Tutorial > What to do if mysql connection error 1130

What to do if mysql connection error 1130

藏色散人
Release: 2023-02-13 10:05:31
Original
14976 people have browsed it

Mysql connection 1130 error solution: 1. Log in to the mysql database with the root user; 2. Change the "host" item in the "user" table in the "mysql" database, and then change it from "localhost" to "%"; 3. Insert the local login user; 4. Use the update method to change the root password; 5. Exit MySQL, comment "skip-grant-tables" in the configuration file, and then restart the mysql service.

What to do if mysql connection error 1130

The operating environment of this tutorial: Windows 10 system, mysql5.5 version, Dell G3 computer.

What to do if mysql connection error 1130?

Connect to MYSQL database and report 1130 error solution

Reinstall MySQL (before reinstalling, check whether the mysql service already exists. If exists, delete the existing mysql service first), because I don’t know the root password before reinstallation, use the password after reinstallation to connect to Mysql data, and always report ERROR 1130: host 'localhost' not allowed to connect to this MySQLserver, cannot Problems with connecting to the database and guessing user permissions and passwords.

1. Log in to the mysql database with the root user

(1) Stop the MySQL service and execute net stop mysql;

(2) Find the configuration file in the installation path of mysql my.ini,

Find [mysqld]

Enter: skip-grant-tables, save

(3) Restart the mysql service, net start mysql;

(4) Execute mysql -uroot -p, press Enter, and press Enter again to enter the mysql database;

2. After logging in to mysql on this machine, change "mysql" The "host" item in the "user" table in the database was renamed from "localhost" to '%'.

mysql>use mysql;
Copy after login

Query the user name of the database

mysql>select host,user,password from user;
Copy after login

Change the host item in the user table to "%"

mysql>update user set host = '%' where user ='root';
mysql>flush privileges;    #刷新用户权限表
mysql>select host,user,password  from user where user='root';
Copy after login

3. Insert local login The user

mysql>insert into user values('localhost', 'root', '', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y','','','','',0,0,0,0,'','');
Copy after login

At this time, the localhost password of the locally connected user is empty

4. Modify the root password

It is normal to modify the root password using the update method

mysql> update user set password=password("123") where user="root";
mysql>flush privileges;
Copy after login

5. Exit MySQL, comment: skip-grant-tables in the configuration file, restart the mysql service

6. Reconnect to the mysql database locally, enter the modified password, the connection is successful

Recommended learning: "MySQL Video Tutorial"

The above is the detailed content of What to do if mysql connection error 1130. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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