MySQL Reset password

Source: Internet
Author: User

Reset the root password for MySQL under Ubuntu

sudo vi/etc/mysql/my.cnf, adding a line "skip-grant-tables" to the [Mysqld] Segment

sudo service mysql restart, restart MySQL services

sudo mysql-u root-p mysql, enter MySQL admin command line with a blank password

(go to MySQL, or use the MySQL command)

Update user set Password=password ("123″) where user= ' root ';, reset the password to 123

(Note that if the user name is not in the table, insert is used)

Quit, exit database management

sudo vim/etc/mysql/my.cnf, comment or delete the line that you just joined "Skip-grant-tables"

sudo service MySQL restart,ok, fix it!

Attention:

In the latest version of MySQL, I was supposed to be MySQL 5.7, he did not have the password field in the database user, with authentication_string

This field is proxy, so the SQL statement should be changed to a more
Update user set Authentication_string=password ("123″) where user= ' root ';

It's OK to do the processing again.

Suggestions:

When MySQL opens a remote connection, the root user is generally not exposed, it is recommended to create a new user, and then expose the newly established users to connect.

MySQL Reset password

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.