六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 24|回复: 0

[转] linux mysql 密码重设

[复制链接]

升级  2.67%

14

主题

14

主题

14

主题

秀才

Rank: 2

积分
54
 楼主| 发表于 2013-2-4 13:36:40 | 显示全部楼层 |阅读模式
长时间没登录mysql ,之前又没把这个密码记录下来,现在密码忘记了!网上找了一下重设mysql 密码的方法,试了一下,成功了!把他共享出来 给大家参考参考 。

1. 先结束mysql 进程
# killall mysqld

2. 用mysql 安全模式运行并跳过权限难
  # mysqld_safe --skip-grant-tables

3. 用root 登录 ,此时不需要密码
# mysql -u root

4. 现在开始修改密码了
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('your new password') where User = 'root' ;
Query OK, 2 rows affected (0.02 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql> quit
Bye

OK,成功了!

注意:当运行' mysqld_safe --skip-grant-tables' 后停在'Starting mysqld daemon with databases from /var/lib/mysql' ,可以新开一个远程终端,继续操作。【转】linux mysql 密码重设
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表