如果忘记了root
密码,需要通过命令操作,实现MySQL密码重置:
停止 MySQL 服务
systemctl stop mysqld
采用命令行参数启动mysql
mysqld_safe --skip-grant-tables &
重置密码(这里将密码重置为123456)
mysql -e "use mysql;update user set password=password('123456') where user='root';"
关闭MySQL进程
killall mysqld
启动MySQL服务
systemctl start mysqld