Home >Database >Mysql Tutorial >How to change mysql username and password

How to change mysql username and password

王林
王林Original
2020-09-02 13:57:348646browse

How to modify the user name and password of mysql: first log in to mysql; then execute the [UPDATE user SET password] command to change the password; then execute the [update user set user] command to modify the user name; and finally refresh the permissions.

How to change mysql username and password

The specific method is as follows:

(Video tutorial recommendation: mysql video tutorial)

Modification Password:

mysql -u root -p
Enter password:***
mysql>use mysql;  选择数据库
Database changed 
mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user='你的用户名';
mysql> FLUSH PRIVILEGES;
mysql> quit;

(Related recommendations: mysql tutorial)

Modify user name:

mysql -u root -p
Enter password:***
mysql> use mysql;  选择数据库
Database changed
mysql> update user set user="新用户名" where user="root";    将用户名为root的改为新用户名
mysql> flush privileges;    刷新权限
mysql> exit

The above is the detailed content of How to change mysql username and password. 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