MySQL is a relational database management system that stores and provides access to data points that are related to one another. MySQL uses Structured Query Language to add, access, and manage content in a database. However, many times MySQL error 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES) appears. Notably, here I will help you to fix this issue by mentioning the reasons that cause the error to appear.
Before reaching the steps to fix the error, you must know how and when this error usually occurs in MySQL. So, read thoroughly to know; the possible reasons for the error to appear.
Reasons for MySQL Error 1045 (28000)
In MySQL, the error 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES) can appear because of the following reasons:
- When the host is not the admin.
- It might happen that the user does not exist on the server.
- Recheck the Login credentials: username and password.
So, here I will explain how to fix the error by providing a solution to the given problems. After that, I will justify the query using a utility.
Fixing the Error 1045 (28000): Access Denied for User ‘root’@’localhost’ (using password: YES) on Windows
Now, we will look into the problem-solving steps for the reasons stated above. Follow the methods given below:
#1. When the Host is not the Admin.
The issue 1045 access denied for user user localhost’ (using password: YES) can also occur when a person is trying to log in from another device. Try to log in from the same device in which you were earlier using the MySQL service.
#2. The user does not exist on the Server.
The user may not exist on the same server that your MySQL is using. This can cause the error: Access denied for user ‘root’@’localhost’ (using password: YES). So, to solve the issue user must be on the MySQL server.
#3. Recheck the Login Credentials: Username and Password.
While Login to the MySQL server users may encounter the given error 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES). This could mean that the password that you entered is wrong, so, to resolve the issue, follow the steps below:
- Open /etc/mysql/my.cnf path from the SSH Server.
- Then add the skip-grant-tables [mysqld] section.
Note: There is no other way to log in besides skip-grant-tables. So, anyone can log in from anywhere and can do anything on the database. skip-grant-tables is a dangerous option. So, we will remove this at the end.
- Restart, MySQL service using the command: service mysql restart
So, now when you log in, ‘skip-grant-tables’ is configured in MySQL.
- Log in to MySQL using: mysql -u root command.
- Then, flush the privileges by using: mysql> flush privileges;
- Here you can set a new password using the command: UPDATE user SET
Password=PASSWORD (‘my_password’) where USER=‘root’;
- After that, remove the skip-grant-tables section from /etc/mysql/my.cnf
- At last, restart and login to the MySQL service using the new password.
You can check your error 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES) is now fixed.
#4. Grant Privileges
This error can also occur when there are no global privileges provided. So, to add the privileges use the given command:
GRANT ALL PRIVILEGES ON database.* TO ‘user’@‘localhost;’
Now, you can check your status for the error. If the error is still not resolved, then you must use the MySQL Database Recovery tool. In the next section, I will brief you on insights into this utility.
MySQL Database Recovery Utility to Recover MySQL Database
MySQL Database Recovery is a prominent tool to recover corrupted MySQL databases. Using the MySQL Database Recovery software, you can restore all your database objects such as views, tables, triggers, and more. Users can recover data from InnoDB and My ISAM engines with ease. The software maintains data integrity throughout the recovery process of corrupt SQL database using smart algorithms. MySQL database recovery software can also solve MySQL error 1146 table doesn’t exist.
So, this was the MySQL error 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES). I have provided quick solutions to fix the error. Work becomes hard when such errors appear and cause trouble while Logging. So, follow all the steps to resolve the error. Moreover, mentioned a quick solution to recover MySQL database using (MySQL Database Recovery) tool. It helps to maintain data integrity throughout the recovery process. To recover from such issues in future preferences. The utility will help you to fix MySQL error 1045.