我已经使用以下步骤重置了MySQL根用户密码
- 停止 MySQL
# systemctl stop mysqld
- 启动安全模式
# mysqld_safe --skip-grant-tables &
- 以 root 用户身份登录
# mysql -u root
- 重置密码
use mysql;
update user set password=PASSWORD("newpassword") WHERE user='root';
flush privileges;
quit;
- 停止 MySQL 安全模式
# systemctl stop mysqld
- 启动我的数据库
# systemctl start mysqld
我在尝试重新启动时收到以下消息
# systemctl restart mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@li1456-180 ~]# systemctl status mysqld.service
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Tue 2016-04-26 07:23:19 UTC; 10s ago
Process: 13293 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 13292 ExecStart=/usr/bin/mysqld_safe (code=exited, status=1/FAILURE)
Process: 13280 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 13292 (code=exited, status=1/FAILURE)
Apr 26 07:23:18 li1456-180.members.linode.com systemd[1]: Failed to start MySQL Community Server.
Apr 26 07:23:18 li1456-180.members.linode.com systemd[1]: Unit mysqld.service entered failed state.
Apr 26 07:23:18 li1456-180.members.linode.com systemd[1]: mysqld.service failed.
Apr 26 07:23:19 li1456-180.members.linode.com systemd[1]: mysqld.service holdoff time over, scheduling restart.
Apr 26 07:23:19 li1456-180.members.linode.com systemd[1]: start request repeated too quickly for mysqld.service
Apr 26 07:23:19 li1456-180.members.linode.com systemd[1]: Failed to start MySQL Community Server.
Apr 26 07:23:19 li1456-180.members.linode.com systemd[1]: Unit mysqld.service entered failed state.
Apr 26 07:23:19 li1456-180.members.linode.com systemd[1]: mysqld.service failed.
我错过了什么吗?
确定答案就在/var/log/messages
在另一个终端上:
tail -f /var/log/messages | grep -i mysql
重启 MySQL
systemctl restart mysqld
检查日志并找到错误,如果仍然无法解决,请发布它,以便我们为您提供更多帮助。