`
liudaoru
  • 浏览: 1554603 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

MySQL数据库中丢失root密码后应当如何补救[z]

阅读更多
From: http://tech.ccidnet.com/art/1108/20071224/1319005_1.html
首先,我们需要结束掉mysql的服务进程。

然后在windows下面一是可以通过任务管理器来结束掉,应该是mysql-nt.exe。二是,如果你的mysql注册为服务的话,可以到服务里面把他先停掉。

在linux或者unix下面直接kill mysql的服务进程就可以。

然后,再用 --skip-grant-tables 选项启动mysql服务。

在windows下面,到mysql安装目录的bin目录下面运行:mysql-nt --skip-grant-tables 就可以启动mysql服务,这样就可以在无密码的状态下进入mysql用mysql -uroot -p

在linux下面 一般mysql服务器目录在:/usr/bin/safe_mysqld --skip-grant-tables,执行就可以启动了。

在Freebsd下面,在/usr/local/etc/rc.d/mysql-server --skip-grant-tables ,执行启动。

其他的Unix系统没有研究过。呵呵。

进入mysql以后,执行一下语句:


use mysql
update user set password=password("new_pass") where user="root";
flush privileges;


最后结我们来结束现在的mysql服务进程,重新启动你的mysql,就可以用你设置的密码登录了。


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics