Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3319238
  • 博文数量: 631
  • 博客积分: 10716
  • 博客等级: 上将
  • 技术积分: 8397
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-01 22:35
文章分类

全部博文(631)

文章存档

2020年(2)

2019年(22)

2018年(4)

2017年(37)

2016年(22)

2015年(1)

2013年(12)

2012年(20)

2011年(19)

2010年(20)

2009年(282)

2008年(190)

分类: Mysql/postgreSQL

2009-04-10 12:52:47

一. MySQL密码的恢复方法之一
如果忘记了MySQL的root密码,可以用以下方法重新设置
1. KILL掉系统里的MySQL进程
killall -TERM mysqld
2. 用以下命令启动MySQL,以不检查权限的方式启动;
safe_mysqld --skip-grant-tables &
3. 然后用空密码方式使用root用户登录 MySQL;
mysql -u root
4. 修改root用户的密码;
mysql> update mysql.user set password=PASSWORD('新密码') where User='root';
mysql> flush privileges;
mysql> quit
重新启动MySQL,就可以使用新密码登录了。
二. MySQL密码的恢复方法二
有可能你的系统没有 safe_mysqld 程序(比如我现在用的 ubuntu操作系统, apt-get安装的mysql) , 下面方法可以恢复
1. 停止mysqld;
   /etc/init.d/mysql stop
(您可能有其它的方法,总之停止mysqld的运行就可以了)
2. 用以下命令启动MySQL,以不检查权限的方式启动;
mysqld --skip-grant-tables &
3. 然后用空密码方式使用root用户登录 MySQL;
mysql -u root
4. 修改root用户的密码;
mysql> update mysql.user set password=PASSWORD('newpassword') where User='root';
mysql> flush privileges;
mysql> quit
重新启动MySQL
/etc/init.d/mysql restart
就可以使用新密码 newpassword 登录了。
阅读(1084) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~