Three methods to solve Navicat for MySQL 1045 error
Navicat will inevitably encounter 1045 when connecting to the MySQL database The error is mainly because the user entered the wrong username or password and was denied access. If you do not want to reinstall, you need to retrieve the password or reset it.
Recommended tutorial: MySQL database introductory video tutorial
Navicat for MySQL 1045 error
Problem description:
1045-Access denied for user 'root'@'localhost' (using password: YES)
Solution To reset the root user password, the steps on the Windows platform are as follows:
Method 1:
1. Log in as the system administrator To the system;
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 put 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 the SQL command from the specified file at startup. The contents of the named file 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.
Method 2:
Directly use the [client] section provided in the /etc/mysql/debian.cnf
file User name and password:
# 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 three:
1. 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 mysql installation directory. Assume the installation directory is d:\mysql\, CMD to enter the command line
3. Run d:\mysql\bin \mysqld-nt –skip-grant-tables
Start mysql and turn off permission checking
4. Run d:\mysql\bin\mysqladmin -u root flush-privileges password “newpassword”
Reset root password
5. Restart the mysql service
The above is the detailed content of How to solve Navicat 1045 access. For more information, please follow other related articles on the PHP Chinese website!