Forgot MySQL root password solution under Ubuntu

Source: Internet
Author: User

1. Forget the MySQL password, the solution found from the Internet is recorded here.

Edit the MySQL configuration file/etc/mysql/my.cnf and add a line "Skip-grant-tables" to the [Mysqld] section.

2. Restart the server: sudo service mysql restart

He will have this situation:

MySQL stop/waiting
MySQL start/running, process 18669

3. Enter the MySQL admin command line with a blank password and switch to the MySQL library. Input: MySQL

4. Then enter:

mysql> use MySQL
Database changed

5. Execute Update user set Password=password ("New_pass") where user= ' root '; Reset the password to New_pass. Exit database Management

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

6. Go back to vim/etc/mysql/my.cnf and comment or delete the line "Skip-grant-tables" that you just joined.

Restart the MySQL service again with the sudo services MySQL restart, login with the new password, and modify the success.

Forgot MySQL root password solution under Ubuntu

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.