解决mysql ERROR 1045 (28000):

来源:互联网 发布:如何申请网址域名 编辑:程序博客网 时间:2024/06/14 07:34

Linux安装mysql成功后出现这个错误
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
解决方法:
vim /etc/my.cnf
在[mysqld]下加入这一行代码

skip-grant-tables

最后重新启动mysql,重新mysql -u root -p 再加回车,password:回车(密码为空 )
如何没有错也就是可以进入mysql,再修改一下user的password,按以下代码顺序

use mysql
 update mysql.user set authentication_string=password('newpass') where user='root' and Host ='localhost';
update user set plugin="mysql_native_password";
flush privileges;
quit;

把之前增加的在my.cnf下的skip-grant-tables删除
登录用mysql -u -p
你的密码,
然后就ok

原创粉丝点击