【linux】Centos下登陆mysql报错#1045 - Access denied for user 'root'@'localhost' (using password: NO)

创建mysql  远程链接

grant all privileges on *.* to 'test'@"%" identified by "test666 with grant option";

flush privileges;

 

在登录时候,无法登录。使用phpmyadmin 保错了:1045 - Access denied for user 'test'@'localhost' (using password: NO)

 

解决方法很简单

 
1.先关闭mysql服务: sudo /etc/init.d/mysqld stop 或者 service mysql stop


2.用管理员身份登陆mysql : mysqld_safe --user=mysql --skip-grant-tables --skip-networking &


3.获取root权限: mysql -u root mysql


4.更改密码: mysql> UPDATE user SET Password=PASSWORD('你想要的密码') where USER='root';


5.归还特权: mysql> FLUSH PRIVILEGES;


6.退出mysql登陆: mysql> quit


7.启动mysql服务: sudo /etc/init.d/mysqld start 或者 service mysql start


8.可以用新密码登陆啦: mysql -uroot -p你的密码

posted @ 2017-09-06 19:27  依然范儿特西  阅读(1725)  评论(0编辑  收藏  举报