Home  >  Article  >  Database  >  How to reset password in mysql5.7

How to reset password in mysql5.7

王林
王林Original
2020-10-16 14:26:593390browse

Mysql5.7 method to reset the password: First execute the [update user set authentication_string = password('123456') where user = 'root';] statement; then restart the mysql service.

How to reset password in mysql5.7

Specific method:

(Recommended tutorial: mysql video tutorial)

Close MySQL5. 7 permission system

Find the configuration file my.cnf of MySQL5.7

Edit and add the code skip-grant-tables at the end of the file

Restart the mysqld service and log in to MySQL

$systemctl restart mysqld

When you log in to mysql at this time, you can log in without a password.

Modify root password

$use mysql;
$select host,user,authentication_string from user;
#修改root密码
$update user set authentication_string = password('123456') where user = 'root';

Enable the permission system, restart MySQL, and log in with a new password

$vim /etc/my.cnf
#开启权限系统
#skip-grant-tables
#重启mysql
$systemctl restart mysqld
#新root密码登陆
$mysql -uroot -p

Related recommendations: mysql tutorial

The above is the detailed content of How to reset password in mysql5.7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn