How to reset MySQL database password

Source: Internet
Author: User
Tags mysql login

One, stop the MySQL service

# Service Mysqld Stop

Second, modify the parameters of the Mysqld_safe

# Mysqld_safe--skip-grant-tables--skip-networking

Parameter explanation:

--skip-grant-tables: Bypass the authorization table so that you can temporarily not require a password when logging in to MySQL.

--skip-networking: There may be a security delay in logging on to the MySQL server without a password, so it is a good idea to turn off network functionality.

Third, start the MySQL service

# service Mysqld Start

This allows you to log in directly to the MySQL server.

# Mysqlwelcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 1Server version:5.5.42-log Source distributiontype ' help, ' or ' \h ' for help. Type ' \c ' to clear the buffer.mysql>

Four, modify the MySQL login password

mysql> Update user Set Password=password (' 123456 ') WHERE user= ' root ' and host= ' 127.0.0.1 ';mysql> update user set P Assword=password (' 123456 ') WHERE user= ' root ' and host= ' localhost ';mysql> FLUSH privileges;

Five, change the Mysqld_safe parameters back.

# service mysqld stop# mysqld_safe service mysqld start# mysqlerror 1045 (28000): Access denied for user ' root ' @ ' lo Calhost ' (using Password:no)



Add:

Common ways to modify MySQL user passwords:

1, # mysqladmin-u root-h 127.0.0.1 password ' 123456 '-p2, mysql> SET password for ' root ' @ ' localhost ' =password (' 123456 ') ; 3. mysql> UPDATE mysql.user SET password=password (' 123456 ') WHERE user= ' root ' and host= ' localhost ';


This article is from the Linux OPS blog, so be sure to keep this source http://hld1992.blog.51cto.com/10543286/1696581

How to reset MySQL database 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.