How to retrieve the mysql password in FreeBSD

Source: Internet
Author: User

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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.