Mysql数据库 Error 1045 错误的原因及解决方法

作者阿里云代理 文章分类 分类:云 知 识 库11 阅读次数 已被围观
 
报错信息
 
ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
 
分析错误的原因:是密码错误导致的。
 
解决办法:
 
1.打开 my.cnf 配置文件:
 
vim /etc/my.cnf
在[mysqld]段加
skip-grant-tables
2.重启服务:
 
/etc/init.d/mysql  restart
3.登陆数据库修改密码:
 
mysql -uroot
use mysql;
select user,host,password from user;
update user set password=password("9ce9023d80") where user="root" and host="localhost";
flush privileges;
exit
 
vim /etc/my.cnf
在[mysqld]段删除
skip-grant-tables
4.重启服务:
 
/etc/init.d/mysql  restart
本公司销售:阿里云、腾讯云、百度云、天翼云、金山大米云、金山企业云盘!可签订合同,开具发票。
?