Skip to content

Instantly share code, notes, and snippets.

@BiosSun
Created September 5, 2013 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BiosSun/6448809 to your computer and use it in GitHub Desktop.
Save BiosSun/6448809 to your computer and use it in GitHub Desktop.
该方法适合在忘记 root 密码时使用,需要有服务器的 root 权限。
# 停止当前mysql服务
/etc/init.d/mysqld stop
# ----
# 启动mysql
/etc/init.d/mysqld start
# 使用空密码登录mysql
mysql -u root
# 进入后修改密码
update mysql.user set password=PASSWORD('your new password') where user='root'
flush privileges;
quit;
# 之后即可使用新密码登录 root 账户
mysql -u root -p
#-> input your new password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment