天天看點

mysql忘記密碼解決辦法

  今天,在新裝的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.正常使用即可

【當你用心寫完每一篇部落格之後,你會發現它比你用代碼實作功能更有成就感!】