Mysql忘记密码恢复

Mysql忘记密码恢复

【1】停止mysql服务 

1.1】 Cmd中停止服务 C:\>net stop mysql MySQL 服务正在停止. MySQL 服务已成功停止

【1.2】或在services.msc中停止服务 找到mysql服务,手动停止。

 

【2】 bin目录下使用mysqld.exe启动

      进入bin 执行 mysqld-nt.exe –skip-grant-tables //以管理员身份执行

                   或者 mysqld --skip-grant-tables //以管理员身份执行

这个时候这个CMD窗口应该是什么也不显示,但是已经定住在那里,mysqld已经启动

 

【3】然后另外打开一个命入令行窗口,执行mysql,此时无需输入密码即可进入。

执行如下操作 C:\>mysql (无需输入密码)

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1 Server version: 5.5.1-m2-community MySQL Community Server (GPL) Type 'help;' or '\h' for help.

Type '\c' to clear the current input statement.

mysql>

【4】执行sql命令

      use mysql update user set password=password("root1234") where user="root";//root1234 是新密码 root是用户名

      flush privileges;

--这个阶段就可以做mysql的表的数据库密码修改,例如可以执行以下命令 这样就完成了密码的修改

【5】结束mysqld进程 windows下直接任务管理器强行关闭

【6】重新开启mysql服务

         C:\>net start mysql

MySQL 服务正在启动 .

MySQL 服务已经启动成功

【7】登陆mysql成功 C:\>mysql -u root –proot1234 // 这里只是证明密码修改成功,这样登陆不安全

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 1 Server version: 5.5.1-m2-community MySQL Community Server (GPL) Type 'help;' or '\h' for help.

Type '\c' to clear the current input statement.

mysql> 密码修改成功

/**************************************End****************************************/

猜你喜欢

转载自vincentboy.iteye.com/blog/2089426