Home > Database > Mysql Tutorial > body text

How to change mysql username and password

王林
Release: 2020-09-02 13:57:34
Original
8595 people have browsed it

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;
Copy after login

(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
Copy after login

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!

Related labels:
source:php.cn
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