How do I forget my sqlroot password in Ubuntu?

Source: Internet
Author: User
In Linux, The MySQLroot password is forgotten Based on Ubuntu12.04LTS.

The solution for forgetting the MySQL root Password in Linux is based on Ubuntu 12.04 LTS.

The solution for forgetting the MySQL root Password in Linux is based on Ubuntu 12.04 LTS.

Forget the mysql password. The solution found on the internet is recorded here.

Edit the mysql configuration file/etc/mysql/my. cnf and add a line "skip-grant-tables" under [mysqld ".

Restart mysql Service

@ Ubuntu :~ $ Sudo service mysql restart
Mysql stop/waiting
Mysql start/running, process 18669

Enter the mysql management command line with an empty password and switch to the mysql database.

@ Ubuntu :~ $ Mysql
Welcome to the MySQL monitor. Commands end with; or \ g.

Mysql> use mysql
Database changed

Run the update user set password = PASSWORD ("new_pass") where user = 'root' command to 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

Return to vim/etc/mysql/my. cnf and comment out or delete the added "skip-grant-tables" line.

Restart the mysql service sudo service mysql restart again and log on with the new password. The change is successful.

@ Ubuntu :~ $ Mysql-uroot-pnew_pass
Welcome to the MySQL monitor. Commands end with; or \ g.
Mysql>

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.