ubuntu 破解mysql密码_Ubuntu下忘记MySQL root密码解决方法
Linux下忘記MySQL root密碼解決方法
忘了mysql密碼,從網上找到的解決方案記錄在這里。
編輯mysql的配置文件/etc/mysql/my.cnf,在[mysqld]段下加入一行“skip-grant-tables”
121201191255521.png
重啟mysql服務
@ubuntu:~$ sudo service mysql restart
mysql stop/waiting
mysql start/running, process 18669
用空密碼進入mysql管理命令行,切換到mysql庫。
@ubuntu:~$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> use mysql
Database changed
執行update user set password=PASSWORD("new_pass") where user='root'; 把密碼重置為new_pass。退出數據庫管理。
mysql> update user set password=PASSWORD("new_pass") where user='root';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4 Changed: 0 Warnings: 0
mysql>quit
``` mysql
回到vim /etc/mysql/my.cnf,把剛才加入的那一行“skip-grant-tables”注釋或刪除掉。
再次重啟mysql服務sudo service mysql restart,使用新的密碼登陸,修改成功。
``` mysql
@ubuntu:~$ mysql -uroot -pnew_pass
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql>
總結
以上是生活随笔為你收集整理的ubuntu 破解mysql密码_Ubuntu下忘记MySQL root密码解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java创建线程哪种方法最好_Java创
- 下一篇: java 释放数组_java集合Arra