How to Fix: Access Denied for User ‘root’@’localhost’ Error on MySQL



RECOMMENDED: Click here to fix Windows errors and optimize system performance

MySQL is an open source database management system based on the SQL language. MySQL comes with the XAMPP control panel, which is also an open source and freely usable application. Recently, however, many reports have been received from users who cannot access their “MySQL” database via their browser and the error “Access Denied for Use’root’ @’localhost'” is displayed.

The reason for this problem is that you do not grant global permissions to the user. So, once you have given the user global permissions for the selection, the problem will be fixed.

In this article, we will guide you in the simplest way to solve this problem and also inform you of the reason for this error. Follow the instructions carefully to avoid further problems.

To resolve the Access denied error for the user ‘root’ @’localhost’ in the MySQL error

  1. Open and edit /etc/my.cnf or /etc/mysql/my.cnf depending on your distribution.
  2. Add the subsidy jump tables in[mysqld].
  3. Restart Mysql
  4. You should now be able to connect to mysql with the following command mysql -u root -p
  5. Run mysql> rinse privileges ;
  6. Set a new password with ALTER USER’root’ @’localhost’ IDENTIFIED by’NewPassword’;
  7. Return to /etc/my.cnf and delete/comment the subsidy jump tables.
  8. Restart Mysql
  9. You can now log in with the new mysql -u root -p password.

Start MySQL in secure mode without password

mysqld_safe –skip-grant-tables &

Warning: It’s dangerous! I had no data in any of my tables, which means I wasn’t worried about malicious readings. The “Skip” option allows anyone to log in with all privileges without a password. If you have concerns about your tables, you should also disable any remote access:



Fix Update July 2019:

We recommend you try using this new tool. It fixes a wide range of computer errors, as well as protecting against things like file loss, malware, hardware failures and optimizes your PC for maximum performance. It fixed our PC quicker than doing it manually:

  • Step 1 : Download PC Repair & Optimizer Tool (Windows 10, 8, 7, XP, Vista – Microsoft Gold Certified).
  • Step 2 : Click “Start Scan” to find Windows registry issues that could be causing PC problems.
  • Step 3 : Click “Repair All” to fix all issues.

download
(optional offer for Advanced System Repair Pro -> Website | EULA | Privacy Policy | Uninstall)



–skip-networking

Another effective workaround solution

Perform the following steps.

Start the MySQL server instance or daemon with the –skip-grant-tables option.

$ mysqld — skip-grant-tables

Follow these instructions.

$ mysql -u root mysql mysql mysql mysql mysql
$mysql> UPDATE user SET Password=PASSWORD(‘my_password’) or USER=’root’ ;
$mysql> PRIVILEGE FLUSHES;

If you are confronted with the unknown field Password error on use:

update user set authentication_string=password(‘my_password’) where user=’root’ ;

Finally, restart the instance/daemon without the –skip-grant-tables option.

/etc/init.d/mysql Restart

You should now be able to log in to your new password.

$ mysql -u root -p

Enter the password: my_password

https://dba.stackexchange.com/questions/147593/access-denied-for-user-rootlocalhost



RECOMMENDED: Click here to troubleshoot Windows errors and optimize system performance