Linux中连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办

这篇文章主要为大家展示了“Linux中连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“Linux中连接MysqL报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办”这篇文章吧。

前言

最近在linux连接MysqL /usr/local/MysqL/bin/MysqL -uroot -p

输入密码出现Access denied for user 'root'@'localhost'(using password: YES)错误。下面话不多说了,来一起看看详细的解决方法

解决办法:

1.先停止MysqL 服务

service MysqLd stop

Linux中连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办


2.进入MysqL安装目录bin/ 使用safe模式,进行重启:

./MysqLd_safe --skip-grant-tables

Linux中连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办


3.使用root账户,无密码登录修改root用户密码

MysqL -u root 
use MysqL
update user set password=PASSWORD("你的密码") where User = 'root';

4.重启MysqL,正常登录

service MysqLd restart 重启

Linux中连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办


/usr/local/MysqL/bin/MysqL -uroot -p  然后输入刚才重置的密码

Linux中连接mysql报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办

以上是“Linux中连接MysqL报错:Access denied for user ‘root’@‘localhost’(using password: YES)怎么办”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享内容对大家有所帮助,如果还想学习更多知识,欢迎关注编程之家行业资讯频道!

相关文章

优化MySQL数据库发布系统存储的方法有:1.mysql库主从读写分...
使用mysql的方法:在“我的电脑”→右键→“管理”→“服务”...
在mysql中查看root用户权限的方法:1.命令行启动mysql服务;...
MySQL主从复制是用来备份一个与主数据库一样环境的从数据库,...
运行mysql的方法1.启动mysql服务,在“我的电脑”→右键→“...
开启mysql的方法1.可以通过快捷键win+r,输入cmd,打开窗口,...