linux下登陆mysql失败
一.提示由于没有密码,拒绝登陆
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
1.关闭mysql
# service mysqld stop
2.屏蔽权限
# mysqld_safe --skip-grant-table
屏幕出现: Starting demo from .....
3.新开起一个终端输入
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql> \q
一开始我使用UPDATE user SET Password=“123” where USER='root';而没有用PASSWORD关键字去设置,每次登陆
[root@localhost wjf]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
使用PASSWORD关键字去设置密码不为明文后,登陆就成功了!
二.提示由于有用户名为空,拒绝登陆
ERROR 1044 (42000): Access denied for user ' '@'localhost' to database 'mysql'
1.关闭mysql
# service mysqld stop
2.屏蔽权限
# mysqld_safe --skip-grant-table
屏幕出现: Starting demo from .....
3.新开起一个终端输入
# mysql -u root mysql
mysql> delete from user where USER='';
mysql> FLUSH PRIVILEGES;//记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql> \q