报错现象:
connect to server at ‘localhost‘ failed
error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: YES)‘
解决方案:
1,执行/etc/init.d/mysqld stop停止mysql服务
2,新开一个终端执行:mysqld_safe --skip-grant-tables &
3,在原来的终端执行命令:/usr/bin/mysql -uroot -p
进行无密码root账号登陆
此时提示输入密码直接Enter键
4,手动修改密码
mysql> use mysql;
Database changed
mysql> UPDATE user set password=password("root") where user=‘root‘ and host=‘localhost‘;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
再次登录:成功!
原文地址:https://www.cnblogs.com/zzvb/p/12445881.html
时间: 2024-11-09 02:10:26