ITPub博客

首页 > 数据库 > MySQL > mysql 忘记密码怎么办?

mysql 忘记密码怎么办?

原创 MySQL 作者:z-bro 时间:2019-04-18 22:54:05 0 删除 编辑
mysql 忘记密码怎么办[@more@]
1.先停掉mysql
# /etc/rc.d/init.d/mysql stop

2.以--skip-grant-table 的參數啟動mysql
# mysql_safe --skip-grant-table&

3. 更改root 密碼 123456
# mysql mysql
mysql> UPDATE user SET password=password('123456') WHERE user='root';
mysql> FLUSH PRIVILEGES;
mysql> exit
4.停掉mysql再重跑
killall mysqld
#/etc/rc.d/init.d/mysqld
# mysql -u root -p
Enter password:
Windows版
首先,停止Mysql服务(net stop mysql),是必须的
shell>mysqld-nt --skip-grant
不要关闭此窗口,然后打开新的CMD窗口

shell>mysql
mysql>use mysql
mysql>update user set password=password('newpassword') where user='root';
mysql>q
shell>
关闭mysqld-nt --skip-grant这个CMD窗口
启动Mysql服务即可。

关闭mysqld-nt --skip-grant窗口后,Mysql服务并没停止
杀掉进程中的mysqld-nt进程后,重启mysql即可。

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

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

注册时间:2008-03-19

  • 博文量
    430
  • 访问量
    348315