sudo passwd root
来更新密码。sudo passwd root
来更新密码。bash, sudo systemctl stop mysql,
`,,2. 启动MySQL到安全模式:,
`bash, sudo mysqld_safe --skip-grant-tables &,
`,,3. 登录MySQL:,
`bash, mysql -u root,
`,,4. 切换到MySQL数据库并更新root密码:,
`sql, USE mysql;, UPDATE user SET authentication_string=PASSWORD('新密码') WHERE User='root';, FLUSH PRIVILEGES;,
`,,5. 退出MySQL并重启MySQL服务:,
`bash, exit, sudo systemctl start mysql,
`,,请将
新密码`替换为你想要设置的密码。Powered By Z-BlogPHP 1.7.3