打开cmd,mysql的root@localhost账户丢失,恢复步骤
注意:需要使用127.0.0.1登录
mysql -h 127.0.0.1 -u root -p
mysql> use mysql;
Database changed
mysql> insert into user set user='root',ssl_cipher='',x509_issuer='',x509_subject='';
Query OK, 1 row affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'root'@'localhost' identified by 'passwd' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
passwd是初始的密码 |