|The root user has the admin privileges. Provide all permissions for the root user to connect from the local system. The grant command will add the privileges to the root command. If you want to revert the privilege, use the ‘revoke’ command. The ‘revoke’ command will remove the privileges from the user.|
MySQL users often face an issue called Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes). This usually occurs when you enter an incorrect password or password for your database. Fixing these credentials can resolve this error in no time.
In this article, we will look at the ways to resolve this error.
How to fix “Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes)”?
The error looks something like this -
It arises when you perform a fresh installation of MySQL and try to login with a password. The default password of MySQL is blank () (i.e. empty string).
So, you can login to the MySQL server using the same password.
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.11-MariaDB mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
The best practice is to change the password after the new installation.
Set root user password
You must set the root user password after performing the new installation. Here is the code to set it –
Now the new password for root user is abc.
How to fix the Error 1045 (28000)?
Let us look at the ways to fix this problem –
The primary method to fix this error is to enter the correct username and password using the following command –
Sometimes, the user you might be trying to access does not exist on the MySQL server. You can check if the user exists using the following code-
If the user does not exist, create it with the desired username.
You might be trying to access the server from a host that is different from the defined host name. You will encounter Error 1045 in this case. You can use this code to view details of the user –
To fix this, you can update the host name for the user using the code below –
You might encounter the error in due to the following scenarios –
This is a very common error that occurs while connecting to a remote database. While connecting to such a database we need to give access to the HOST IP ADDRESS to connect to it.
This is the IP Address of the source system which connects to the database server.
If access is not given, then run the given command –
CREATE USER 'dbuser1'@'< Host IP >' IDENTIFIED VIA mysql_native_password USING '***';GRANT ALL PRIVILEGES ON *.* TO 'dbuser1'@'< Host IP >' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
Apart from all this, make sure the host contains the correct IP address and host name, to avoid the Error 1045 (28000) access denied for user 'root'@'localhost' (using password: yes).
You may see something like this;
Securing the MySQL server deployment.
If you see it says
Watch the last 10 minutes of this video, it teaches you how you do it.
How do I fix Access denied for user root localhost using password yes?
Use the ALTER USER command and change the authentication method to log into MySQL as root: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; This command changes the password for the user root and sets the authentication method to mysql_native_password.
How do I fix access to localhost is denied?
A restart of Chrome always solved the issue.
What does using password no mean in MySQL?
For example, if you get an error message that contains using password: NO , it means that you tried to log in without a password. If you get an Access denied error when trying to connect to the database with mysql -u user_name , you may have a problem with the user table.
What is the password for root localhost in MySQL?
The default user for MySQL is root and by default it has no password.