When I used freebsd for the first time, the result was that after the various passwords were configured, I could not remember the root password of mysql. Now I have folded it back and found a way to crack the mysql password, this requires the root permission of the server.
Note that the solution is different from that in linux.
The Code is as follows: |
Copy code |
# Killall-TERM mysqld // first kill all mysql Processes #/Usr/local/bin/mysqld_safe -- skip-grant-tables & |
Will return
The Code is as follows: |
Copy code |
100723 22:19:53 mysqld_safe Logging to '/var/db/mysql/FreeBSD. err '. 100723 22:19:53 mysqld_safe Starting mysqld daemon with databases from/var/db/mysql 100723 22:19:53 mysqld_safe mysqld from pid file/var/db/mysql/FreeBSD. pid ended [1] Done mysqld_safe-skip-grant-tables |
If this information appears, it will be half done.
The Code is as follows: |
Copy code |
# Mysql-uroot Mysql> use mysql; Database changed Mysql> update user set password = PASSWORD ('Password') where user = 'root' Query OK, 0 rows affected (0.00 sec) Rows matched: 4 Changed: 0 Warnings: 0 Mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
|
Another solution for retrieving the root password
Directly use the username and password provided in the [client] section of the/etc/mysql/debian. cnf file:
The Code is as follows: |
Copy code |
# Mysql-udebian-sys-maint-p Enter password: <enter the password in the [client] section> Mysql> update user set password = password ('newpassword') where user = 'root '; Mysql> flush privileges; Mysql> quit # Mysql-uroot-p Enter password: <enter the new password newpassword> |