MySQL database forgot password

Source: Internet
Author: User

MySQL database forgot password what to do?

ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)

Such an error is usually the user password does not match, either re-enter the correct password, or forget the password, need to change the password. So how do I change the password?


1. Setting and modifying user passwords

To modify a user password:

Method 1: Outside of database modification

# mysqladmin-uroot-p123 password ' 456 '


Method 2: Log in to the database to make changes

# mysql-uroot-p456 mysql> UPDATE mysql.user SET password=password (' 123 ') WHERE user= ' root ' and host= ' localhost ';              #函数的方式 can also use MD5, which defaults to the function mysql> FLUSH privileges; #刷新系统权限相关表


Method 3: Log in to the database to make changes

# mysql-uroot-p456 Mysql> Set Password=password (' 123 ');mysql> flush privileges;


2. Forget the root user password

Add parameter--skip-grant-tables at startup, enter database to change password

#/etc/init.d/mysql Stop # mysqld_safe--user=mysql--skip-grant-tables--skip-networking & # mysql-u root MySQL mysq l> UPDATE user SET Password=password (' NewPassword ') where user= ' root '; mysql> FLUSH privileges; Mysql> Quit #/etc/init.d/mysql Restart # mysql-uroot-p Enter Password: < Enter new password newpassword>


This article is from the "Lanzhi" blog, make sure to keep this source http://7826443.blog.51cto.com/7816443/1715815

MySQL database forgot 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.