mysql root帐号丢失解决办法

一.windows系统的解决方法
1.首先以系统管理员身份登陆系统。
2.停止MySQL的服务。
3.进入命令窗口,然后进入MySQL的安装目录,比如我的安装目录是c:\mysql,进入C:\mysql\bin
4.跳过权限检查启动MySQL,c:\mysql\bin>;mysqld-nt –skip-grant-tables
(或者将–skip-grant-tables写入my.ini中,重新启动Mysql,即可设置新密码)。
5.重新打开一个窗口,进入c:\mysql\bin目录,设置root的新密码
c:\mysql\bin>mysqladmin -u root flush-privileges password “newpassword”
c:\mysql\bin>mysqladmin -u root -p shutdown
将newpassword替换为你要用的root的密码,第二个命令会提示你输入新密码,重复第一个命令输入的密码。
6.停止MySQL Server,用正常模式启动Mysql
7.你可以用新的密码链接到Mysql了。

二.Unix/Linux的解决方法
1.用root或者运行mysqld的用户登录系统;
2.利用kill命令结束掉mysqld的进程;
3.使用–skip-grant-tables参数启动MySQL Server
shell>mysqld_safe –skip-grant-tables &
4.为root@localhost设置新密码
shell>mysqladmin -u root flush-privileges password “newpassword”
5.重启MySQL Server

此条目发表在 Database 分类目录,贴了 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">