Home > Database > Mysql Tutorial > body text

mysql修改根用户密码_MySQL

WBOY
Release: 2016-06-01 13:38:35
Original
1316 people have browsed it

bitsCN.com

mysql修改根用户密码

 

忘记ROOT密码时    

1、编辑mysql配置文件:

windows环境中:%mysql_installdir%/my.ini //一般在MYSQL安装目录下有my.ini即MYSQL的配置文件。

linux环境中:/etc/my.cnf

在[mysqld]配置段添加如下一行:

skip-grant-tables

保存退出编辑。

 

2、然后重启mysql服务

windows环境中:

net stop mysql

net start mysql

linux环境中:

/etc/init.d/mysqld restart

 

3、设置新的ROOT密码

然后再在命令行下执行:

mysql -uroot -p mysql

直接回车无需密码即可进入数据库了。

现在我们执行如下语句把root密码更新为 7758521:

update user set password=PASSWORD("7758521") where user='root';

quit 退出MYSQL。

 

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

然后修改mysql配置文件把刚才添加的那一行删除。

再次重起MYSQL服务,密码修改完毕。

 

bitsCN.com
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!