1. 程式人生 > >mysql忘記密碼解決辦法

mysql忘記密碼解決辦法

con oot color nec its 通過 驗證 rest state

  今天,在新裝的mysql上限制只能通過127.0.0.1登錄之後怎麽也登錄不上。

1.在my.cnf最後一行(或者mysqld下面)設置跳過密碼驗證的過程(windows是my.ini)

skip-grant-tables

2.重啟mysql服務

service mysqld restart

3.直接輸入mysql即可

[root@VM_0_12_centos ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id 
is 1313 Server version: 5.6.41 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type help; or \h for
help. Type \c to clear the current input statement.

4.修改密碼:

update user set Password=PASSWORD("newword") where user=root;

5.使修改生效

flush privileges;

6.修改完之後記得去掉跳過密碼驗證的設置,修改/etc/my.cnf去掉設置

7.正常使用即可

mysql忘記密碼解決辦法