The first step:
Using this method to experiment, I found that this is not the case because I have no empty user:
First, the phenomenon: the MySQL database of the company Linux system root user set password, but often with the command ' mysql-u root-p ' login error, and sometimes can log in. Login error message: [[[email protected] ~]# mysql-u root-penter password:error 1045 (28000): Access denied for user ' root ' loc Alhost ' (using Password:yes) Two, reason: the existence of empty users in the database three, processing methods: 1, disable MySQL service: # service MySQL stop2, input command: # Mysqld_safe--user=mysql- -skip-grant-tables--skip-networking & 3, log in database: # mysql-u root mysql4, mysql> use mysql;5, mysql> select User,hos T,password from user; The results are as follows: +------+-----------------------+----------+| user | Host | Password |+------+-----------------------+----------+| Root | % | Mima | | Root | Localhost.localdomain | Mima | | Root | 127.0.0.1 | Mima | | | localhost | || | Localhost.localdomain | |+------+-----------------------+----------+6, remove the empty user from the above query:mysql> delete from user where user= '; 7, exit database: MySQL > quit8, start MySQL service: # service MySQL Start9, re-use command ' Mysql-u root-p' Login, ok!
But there's another way to log in without a password: Add a line to/ETC/MYSQL/MY.CNF
Yes, that's right. Add Skip-grant-tables
Then sudo service MySQL restart
Step Two:
Looking for new ways to Http://www.bitscn.com/pdb/mysql/201407/226146.html
MySQL Error 1045 (28000) errors occurred