MYSQL problem solution: Access denied for user 'root'@'localhost' (using password:YES)

When developing a Web project in MyEclipse in the past two days, there was a problem connecting to the MYSQL database: Access denied for user 'root'@'localhost' (using password:YES).

        After searching the information, it is found that the root account does not open remote access permissions by default, so it is necessary to modify the relevant permissions.

      solution:
  1. Open the my.ini file in the MySQL directory, add a line of "skip-grant-tables" at the end of the file, save and close the file. (WIN7 is installed by default, my.ini is in C:\ProgramData\MySQL\MySQL Server 5.6)
  2. Restart the MySQL service.
  3. Enter the MySQL BIN directory through the command line, enter "mysql -u root -p" (without entering a password), and press Enter to enter the database. (WIN7 is installed by default, and the BIN directory is: C:\Program Files\MySQL\MySQL Server 5.6\bin)
  4. Execute "use mysql;" to use the mysql database.
  5. Execute "update user set password=PASSWORD("123456") where user='root';" (modify root's password)
  6. Open the my.ini file in the MySQL directory, delete the "skip-grant-tables" in the last line, save and close the file.
  7. Restart the MySQL service.
  8. Enter "mysql -u root -p 123456" in the command line to successfully connect to the database.

      After completing the above steps, MyEclipse can also successfully connect to MySQL.


      

----------------------------- The above is for the case where the above method does not work------------ ----------------------

1. Shut down the MySQL service

2. Name the new text file arbitrarily, such as mysql.txt, and put it in the MySQL installation folder, such as C:MYSQL\mysql.txt

3. The content of the file is set authentication_string for 'root'@'localhost' = password('newPassword');

3. Open the dos system and open to the installed bin directory to execute mysqld -nt --init-file=C:MYSQL\mysql.txt  

4. After the execution, the console opens the MySQL service net start mysql, prompting the server to start successfully;

5. Delete the mysql.txt file, open another dos console, enter mysql --uroot -p Enter, and then enter the password modified above; after entering, enter the mysql> edit box;

6. \q to exit;

The above is the solution to the error I summarized online. Welcome to adopt.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325162703&siteId=291194637