Home > Database > Mysql Tutorial > body text

linux服务器忘记mysql密码的解决方法

WBOY
Release: 2016-06-07 17:51:29
Original
1137 people have browsed it

本文章介绍了是在linux服务器中,把mysql数据库服务器的密码给忘了的处理方法,下面我们只要一步步操作就可以找回密码了哦。

1、ssh登陆到linux服务器,向d server 发送kill命令关掉mysqld server(不是 kill -9),存放进程ID的文件通常在mysql的所在的目录中。(命令输入部分用红色标注)
  

 代码如下 复制代码
#killall -TERM mysqld
  2、使用`--skip-grant-tables' 参数来启动 mysqld(/www/wdlinux/mysql/bin/为wdcp系统的mysql路径,非此系统的,请变更mysql的路径)。

 代码如下 复制代码

#cd /www/wdlinux/mysql/bin/

#mysqld_safe --skip-grant-tables

启动后的状态,如图:

 

 


 

3、 原有的ssh客户端不要关闭(若该客户端超时,可能导致重置密码失败,所以重置密码过程建议在几分钟内完成),新开一个ssh客户端登陆,登陆后输入mysql命令登陆到mysql:

>mysql

然后输入以下命令重置密码:

 代码如下 复制代码
  >use mysql
  >update user set password=password("123456") where user="root";
  >flush privileges;
如图:

4、输入命令:

 代码如下 复制代码

#killall -TERM mysqld


#service mysqld start

5、用新密码登陆试试

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!