Home > Database > Mysql Tutorial > body text

忘记mysql root密码应该如何找回?

WBOY
Release: 2016-06-07 17:54:20
Original
917 people have browsed it

忘记MySQL(和PHP搭配之最佳组合) ROOT密码是在MySQL(和PHP搭配之最佳组合)使用中很常见的问题,可是有很多朋友并不会重置ROOT密码,那叫苦啊,我有深有感触,特写此文章与大家交流: 1、编辑MySQL(和PHP搭配之最佳组合)配置文件: windows环境中:%MySQL(和P

忘记MySQL(和PHP搭配之最佳组合) ROOT密码是在MySQL(和PHP搭配之最佳组合)使用中很常见的问题,可是有很多朋友并不会重置ROOT密码,那叫苦啊,我有深有感触,特写此文章与大家交流:

1、编辑MySQL(和PHP搭配之最佳组合)配置文件:

windows环境中:%MySQL(和PHP搭配之最佳组合)_installdir%\my.ini //一般在MySQL(和PHP搭配之最佳组合)安装目录下有my.ini即MySQL(和PHP搭配之最佳组合)的配置文件。
linux环境中:/etc/my.cnf

在[MySQL(和PHP搭配之最佳组合)d]配置段添加如下一行:
skip-grant-tables

保存退出编辑。

2、然后重启MySQL(和PHP搭配之最佳组合)服务

windows环境中:
net stop MySQL(和PHP搭配之最佳组合)
net start MySQL(和PHP搭配之最佳组合)

linux环境中:
/etc/init.d/MySQL(和PHP搭配之最佳组合)d restart

3、设置新的ROOT密码

然后再在命令行下执行:
MySQL(和PHP搭配之最佳组合) -uroot -p MySQL(和PHP搭配之最佳组合)
直接回车无需密码即可进入了。

现在我们执行如下语句把root密码更新为 7758521:
update user set password=PASSWORD("7758521") where user='root';

quit 退出MySQL(和PHP搭配之最佳组合)。

4、还原配置文件并重启服务

然后修改MySQL(和PHP搭配之最佳组合)配置文件把刚才添加的那一行删除。

再次重起MySQL(和PHP搭配之最佳组合)服务,密码修改完毕。

修改完毕。

用新密码7758521试一下吧,又能登入MySQL(和PHP搭配之最佳组合)的感觉就是不一样吧?

技术交流 永无止境

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!