Home > Database > Mysql Tutorial > Introduction to various methods of changing root password in mysql

Introduction to various methods of changing root password in mysql

王林
Release: 2020-01-28 21:23:19
forward
2073 people have browsed it

Introduction to various methods of changing root password in mysql

There are many situations to modify the root password, the details are as follows:

Before the root password is not set:

SET PASSWORD command Method:

mysql -u root
mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('你要设置的密码');
Copy after login

mysqladmin command method: (Related video tutorial recommendation: mysql video tutorial)

mysqladmin -u root password "你要设置的密码"
Copy after login

UPDATE method to directly edit the user table:

mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password = PASSWORD('你要设置的密码') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
Copy after login

After setting root:

Mysqladmin method:

mysqladmin -u root password oldpass "你要设置的新密码"
Copy after login

Set the root password, but forgot:

mysqld_safe --skip-grant-tables&mysql -u root mysql
mysql> UPDATE user SET password = PASSWORD("你要设置的新密码") WHERE user = 'root' ;
mysql> FLUSH PRIVILEGES;
Copy after login

Related article tutorials Recommended: mysql tutorial

The above is the detailed content of Introduction to various methods of changing root password in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template