Access denied for user ''@'localhost' to database 'mysql'问题


Access denied for user ''@'localhost' to database 'mysql'问题

MySQL: Access denied for user '' @ 'localhost' to database 'mysql' issues spectacle.
Read the original starmyao Last post on 2018-08-24 21:10:23 number 7880 collection
launched

 Problem Description:
    MySQL command line, landing root account when the password is not empty, but the implementation of 'use mysql;' command, always prompt: 'Access denied for user "@ ' localhost 'to database' mysql '' .
   a close look at the error message Access denied for user '' @ ' localhost' to database 'mysql', meaning: denial user to "account login, use an empty password for the anonymous user does not have permission, your password and forget . No way that only their own password.

A way to solve the problem of root password

  Found under the MySQL installation directory my.ini file, edit, find [mysqlId], after adding skip-grant-tables (skip Authorization Form), then restart the MySQL service, open a command line, you can use a blank password. (Remember to restart the service)

MySQL the root -p -u 1.
2. // entering a password using the transport, with a blank password login
3. MySQL> MySQL use;
4. MySQL> Update User password SET PASSWORD = ( 'Enter your new password to herein single quotes') WHERE User = 'the root';
5. The MySQL> the flush privileges;

2. In this case, restart the MySQL service, and then reopen the console. 
3. Remember that the last line in my.ini file to add configuration skip-grant-tables to delete, delete, to restart the service. Use the new password.

Second problem solving 'localhost' way
 after the procedure described above, or reject the user to "account login. What is the reason? N in the online search for a long time I did not see why.
And the previous operation, skip the grant tables empty password to enter mysql, view the user table.
 
 user | password | Host |
+ ------ + -------------------------- -------------------------- ----------------------- + + ---
| root | * 8 ************************************** D |% |
| root | * 8 ************************************** D | localhost.localdomain |
| root | * 8 ************************************** D | 127.0.0.1 |
| root | * 8 ************************************** D | :: 1 |
| | | localhost |
| | | Localhost.localdomain |
| DCH | * 8 ************************************** D |% |
| DCH | * 8 ************************************** D | localhost |
 
 found my localhost root user had no rights? Login ok in mysql -uroot -p -h127.0.0.1!
 That is not licensed to "localhost".  
 I remember when authorizing the use of '%', why not "localhost" it? Here in% it represents all of the host can remotely access the mysql.
 But after inquiries mysql official documentation, '%' does not include localhost! Why is it so, unfriendly, and quickly to localhost% have carried out empowerment.
 All privileges ON * * Grant to root @ "localhost" IDENTIFIED by "password";. 
 flush privileges;
login is successful!

Solve Access denied for user '' @ ' localhost' to database 'mysql' problem
original Hello tornado! ! ! Last post on 2018-10-15 17:50:20 reading number 6093 collection
launched
after Changing the root password mysql, and then landing, an error such as the title, after looking for some answers, and finally resolved, follow these steps:

1. stopped mysql: service mysqld stop

2. Use the state does not validate the login mysql:    

          mysqld_safe --skip-grant-tables & // background

          Start mysql: service mysqld start

3. Go to mysql: mysql -u root

4.use mysql;

5. update user set password = password ( "new_pass") where user = "root"; // 'new_pass' where you want to set a password

or

5.delete from user where user = ''; delete user space

 

6,flush privileges;

7,quit

8.service mysqld restart

9. Re-enter the mysql -utoot -p

Then enter the password will find that the problem has been resolved  

 

Guess you like

Origin www.cnblogs.com/xianz666/p/12562783.html