The root user name in ubuntu cannot enter mysql, how to view the user name and password, and how to repair _ MySQL

Source: Internet
Author: User
The root user name in ubuntu cannot go to mysql. how can I view the user name and password, and how can I modify the root password in Ubuntu?

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.