重置MySQL密码

You are here:

如何重置数据库root密码?

如果忘记了root密码,需要通过命令操作,实现MySQL密码重置:

  1. 停止 MySQL 服务

    systemctl stop mysqld
    
  2. 采用命令行参数启动mysql

    mysqld_safe --skip-grant-tables &
    
  3. 重置密码(这里将密码重置为123456

    mysql -e "use mysql;update user set password=password('123456') where user='root';"
    
  4. 关闭MySQL进程

    killall mysqld
    
  5. 启动MySQL服务

    systemctl start mysqld
    
Was this article helpful?
Dislike 0
浏览量: 26