ITPub博客

首页 > 数据库 > MySQL > MySQL 忘记root密码修改方法备忘

MySQL 忘记root密码修改方法备忘

原创 MySQL 作者:zhenyongwei 时间:2016-02-29 10:34:59 0 删除 编辑
方法一:  
# /etc/init.d/mysql stop  
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &  
# mysql -u root mysql  
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=root’;  
mysql> FLUSH PRIVILEGES;  
mysql> quit  
# /etc/init.d/mysql restart  
# mysql -uroot -p  
Enter password: <输入新设的密码newpassword>  
登陆后再set 下密码
mysql>  set password=password('root');
方法二:  
直接使用/etc/mysql/debian.cnf文件中[client]节提供的用户名和密码:  
# mysql -udebian-sys-maint -p  
Enter password: <输入[client]节的密码>  
mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’;  
mysql> FLUSH PRIVILEGES;  
mysql> quit  
# mysql -uroot -p  
Enter password: <输入新设的密码newpassword

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30623428/viewspace-2015805/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-12-09

  • 博文量
    17
  • 访问量
    40480