Home  >  Article  >  Database  >  How to solve the 1045 error in navicat

How to solve the 1045 error in navicat

王林
王林forward
2020-12-23 10:02:5221936browse

How to solve the 1045 error in navicat

Problems that arise:

(Learning video sharing: Programming video )

1045-Access denied for user 'root'@'localhost'(using password: YES)

Cause analysis:

Mainly because the user entered an incorrect username or password and was denied access. If you do not want to reinstall, you need to retrieve or reset your password.

The solution is to reset the root user password. The steps on the Windows platform are as follows:

Method 1:

1. Log in to the system as a system administrator;

2. If the MySQL server is running, stop it.

If the server is running as a Windows service, enter the service manager: Start menu->Control Panel->Administrative Tools->Services; if the server is not running as a service, you may need to use task management to force stop it.

3. Create a text file and place the following command on a single line:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPassword');

Save the file with any name. In this example, the file is C:\mysql-init.txt.

4. Enter the DOS command prompt: Start menu->Run-> cmd

Assume that you have installed MySQL to C:\mysql. If you installed MySQL in another location, please adjust the following commands accordingly.

In the DOS command prompt, execute the command:

C:\> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt

When the server starts, execute the "--init-file" option to read SQL from the specified file at startup The contents of the file named by the command change the root user password. When the server starts successfully, C:\mysql-init.txt should be deleted.

5. Stop the MySQL server and then restart it in normal mode.

If you run the server as a service, you should start it from the Windows Services window; if you started the server manually, you can use the commands as normal.

Method 2:

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where
USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>

Method 3:

Directly use the username and password provided in the [client] section of the /etc/mysql/debian.cnf file:

# mysql -udebian-sys-maint -p
Enter password: <输入[client]节的密码>
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where
USER=’root’;
mysql> FLUSH PRIVILEGES;
mysql> quit
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>
mysql>

Method 4:

1. The administrator logs in to the system, stops the mysql service or ends the mysqld-nt process

2. Enter the command line and go to the installation directory of mysql. Assume the installation The directory is d:\mysql\, CMD to enter the command line

3. Run d:\mysql\bin\mysqld-nt --skip-grant-tables to start mysql and turn off permission checking

4. Run d:\mysql\bin\mysqladmin -u root flush-privileges password "newpassword" to reset the root password

5. Restart the mysql service

Related recommendations: navicat

The above is the detailed content of How to solve the 1045 error in navicat. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete