Heim >Datenbank >MySQL-Tutorial >忘记mysql的root密码重置方法_MySQL

忘记mysql的root密码重置方法_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:49:211061Durchsuche

bitsCN.com

如果忘记了 MySQL 的 root 密码,可以用以下方法重新设置:

linux操作方法

在my.cnf的[mysqld]字段加入:

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

然后重启你的mysqld,这样久没有密码了.

然后进入mysql。

 
UPDATE mysql.user SET Password=PASSWORD
('password') WHERE User='root';
 

成功后

 
 FLUSH PRIVILEGES;
 

最后去掉my.cnf中的skip-grant-tables

重启mysqld。

 

windows操作方法

1. KILL掉系统里的MySQL进程;

2. 用以下命令启动MySQL,以不检查权限的方式启动;

 
mysqld_safe -skip-grant-tables &
 


3. 然后用空密码方式使用root用户登录 MySQL;

 

 
mysql -u root 


4. 修改root用户的密码;

 


mysql> update mysql.user set password=PASSWORD(’ www.hzhuti.com ’) where User=’root’;
mysql> flush privileges;
mysql> quit 

5. 重新启动MySQL,就可以使用新密码登录了。

bitsCN.com
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn