The root User Name in ubuntu cannot go to mysql. How can I view the user name and password and change the root password?

Source: Internet
Author: User

The root User Name in ubuntu cannot go to mysql. How can I view the user name and password and change the root password?
Mysql-u root-p Press enter. after entering the password, the system prompts "access denied... ues password YES/NO" error.

Step 1:

In this case, you need to enter the/etc/mysql directory, and then sudo vim/vi debian. cnf view the username and password in the file, and then use the username and password in the file to enter mysql. If debian. if the user name in cnf is debian-sys-maint, then:

Mysql-u debian-sys-maint-p press Enter. In this case, you need to enter the password and copy the password in debian. cnf (do not enter it manually because it is prone to errors ).

Now you can access mysql.

Step 2:

Change root Password

Log on to the mysql client according to the previous step.
Mysql> use mysql;
Database changed
Mysql> update user set password = password ('new password') where user = 'root ';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql> quit

Step 3:

Use the newly changed root and password to log on and view.

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.