在Ubuntu中忘记mysql密码_Ubuntu下忘记MySQL密码重设方法

http://www.cnblogs.com/yuxc/archive/2012/07/25/2607587.html

1、结束当前正在运行的mysql进程。

# /etc/init.d/mysql stop

2、用mysql安全模式运行并跳过权限验证。

# /usr/bin/mysqld_safe --skip-grant-tables

3、重开一个终端以root身份登录mysql。

# mysql -u root

4、修改root用户口令。

mysql> use mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> update user set Password = PASSWORD('root') where User ='root';

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

mysql> exit

5、结束mysql安全模式,用正常模式运行mysql。

# /etc/init.d/mysql restart

6、试试你新修改的口令

mysql> show grants for 'root'@'127.0.0.1';

mysql> flush privileges;

mysql> quit

1 mysql>use mysql2 Reading table information for completion of table andcolumn names3 You can turn off this feature to get a quicker startup with -A4

5 Database changed6 mysql> update user set Password = PASSWORD('root') where User ='root'

7 ->;8 Query OK, 4 rows affected (0.06sec)9 Rows matched: 4 Changed: 4Warnings: 010

11

12

13 ysql> select user,password fromuser;14 +------------------+-------------------------------------------+

15 | user | password |

16 +------------------+-------------------------------------------+

17 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

18 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

19 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

20 | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |

21 | debian-sys-maint | *422D1AF27E5E185185FE7E0C56187AB7396542D0 |

22 +------------------+-------------------------------------------+

23 5 rows in set (0.00sec)24

25 mysql>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值