密碼這東西,好像除了黑客,最大的敵人就是自己了......................
打開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)