MySQL重置root密碼


密碼這東西,好像除了黑客,最大的敵人就是自己了......................

打開mysql的配置文件my.cnf

找到[mysqld]

插入skip-grant-tables(免密登錄)   保存退出

然后重啟mysql  service mysqld restart  

再次打開就直接進來了

 

然后我們直接mysql進入數據庫添加密碼

 1 MySQL [(none)]> use mysql;
 2 Database changed
 3 MySQL [mysql]> update user set password=password("!123456q") where user="root";
 4 Query OK, 4 rows affected (0.00 sec)
 5 Rows matched: 4  Changed: 4  Warnings: 0
 6 
 7 MySQL [mysql]> flush privileges;
 8 Query OK, 0 rows affected (0.00 sec)
 9 
10 MySQL [mysql]> quit
11 Bye

然后回去取消掉,免密登錄(skip-grant-tables)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM