Home > Database > Mysql Tutorial > body text

MySQL忘记密码怎么恢复密码(windows/linux)?

WBOY
Release: 2016-06-07 17:52:12
Original
1068 people have browsed it

本文章介绍了关于MySQL忘记密码怎么恢复密码?,有碰到此类问题的朋友可参考一下。

windows服务器下

1、停止mysql服务(以管理员身份,在cmd命令行下运行)使用如下命令:

 代码如下 复制代码
net stop mysql

attachments/201209/22_164341_.jpg



  2、.使用命令启动mysql数据库,命令如下

 代码如下 复制代码
mysqld - -skip-grant-tables

 

attachments/201209/22_164416_.jpg



3.新开一个cmd窗口,进行如下命令操作

 代码如下 复制代码
1、mysql -uroot
2、update mysql.user set password=password('你的密码') where user='root;


如图:

attachments/201209/22_164457_.jpg



在linux下:

如果 MySQL 正在运行,首先杀之: killall -TERM mysqld。
启动 MySQL :bin/safe_mysqld --skip-grant-tables &
就可以不需要密码就进入 MySQL 了。
然后就是

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

重新杀 MySQL ,用正常方法启动 MySQL 。

相关文件可参考:http://www.111cn.net/database/mysql/41423.htm

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!