How to Fix this Error – Access Denied For User ‘Root’@’Localhost’

The ERROR 1698 (28000): How to Fix this Error – Access Denied For User ‘Root’@’Localhost’ was experienced by the majority of MySQL users. When you attempt to connect to MySQL as the root user on a new installation, this error message frequently appears.

You can rapidly fix the access denied for user root on the localhost issue by following the instructions in this manual. The described procedures are valid for both MariaDB and MySQL. There won’t be a requirement for intricate arrangements or table modifications.

  • Access to a terminal or command line
  • Installation of MariaDB or MySQL
  • User with sudo or root access

How to Access MySQL as Root?

The command you use when installing MySQL and attempting to access it on a local machine as the root user is:

  • MySQL -u root -p

How to Fix this Error – Access Denied For User ‘Root’@’Localhost’ will typically appear.

One MySQL command will enable root access.

Fix This Error Access Denied For User Root

Use sudo to change the root user before you can log into MySQL as root:

  • enter MySQL

In the space provided, type your password. The MySQL shell starts up.

To log into MySQL as root, use the ALTER USER command and modify the authentication strategy:

  • ALTER USER "root"@"localhost" IDENTIFIED BY "MySQL native password" "insert password" BY;

With this command, the root user’s password is updated, and MySQL native password is selected as the authentication method. This is a conventional authentication mechanism, and it is less safe than auth plugin.

Although we used “root” as the password in the aforementioned example, we strongly advise you to choose something more secure.

Test Root User Access to MySQL

After executing the aforementioned commands, end the MySQL shell by typing exit and pressing enter or by pressing CTRL + D on your keyboard. In order to log in, the MySQL service does not need to be restarted.

Now attempt to access MySQL as root once more. the following into the terminal:

  • root MySQL -u -p

the password you entered when you executed the ALTER USER command. Entering the system password will not allow you to access MySQL. The welcome message from MySQL should appear if everything went according to plan.

Conclusion

You now understand how to avoid MySQL ERROR 1698 (28000): For the user How to Fix this Error – Access Denied For User ‘Root’@’Localhost’ access is denied.

There are various approaches to solving this problem, but we chose the quickest and most straightforward one. To prevent SQL syntax errors, be sure to enter the commands exactly as they are listed in the article.

Category:

Share:

70%OFF

Flash Sale

Hurry Up! Offer ends in
02 days
06 hrs
28 mins
32 secs
Buy Now