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