1 连接数据库,Access Denied
使用./mysql -uroot -padmin 连接Mysql时出现了:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
2 密码重设步骤
2.1 检查MySQL服务,若启动,则关闭;
[root@master bin]# whereis mysql
[root@master bin]# chkconfig --list | grep -i mysql
[root@master bin]# service mysql stop
2.2 使用mysqld_safe脚本启动MySQL,连接MySQL;
[root@master bin]# ./mysqld_safe --user=root --skip-grant-tables --skip-networking &
./mysql -uroot mysql
2.3 执行SQL语句,更新密码;
mysql> update user set password=password('123456') where user='root';
Query OK, 1 row affected (0.07 sec)
Rows matched: 5 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> quit
Bye
2.4 重启服务,连接Mysql
[root@master bin]# service mysql stop
Shutting down MySQL..160203 10:53:47 mysqld_safe mysqld from pid file /var/lib/mysql/master.pid ended
SUCCESS!
[1]+ Done ./mysqld_safe --user=root --skip-grant-tables --skip-networking
[root@master bin]# service mysql start
Starting MySQL. SUCCESS!
[root@master bin]# ./mysql -uroot -p123456
资源链接
- [ Linux命令大全 ] : http://www.runoob.com/linux/linux-command-manual.html
- [mysqld与mysqld_safe区别] : http://blog.youkuaiyun.com/rj03hou/article/details/5143434
本文介绍了解决MySQL登录失败的问题,并提供了一种通过重置密码来恢复正常登录的方法。文章首先展示了登录失败时出现的具体错误信息,然后详细解释了如何通过一系列命令关闭MySQL服务、启动MySQL服务并跳过权限表,最终更新root用户的密码。
644

被折叠的 条评论
为什么被折叠?



