Home  >  Article  >  Database  >  MySQL creates user accounts and deletes user accounts

MySQL creates user accounts and deletes user accounts

巴扎黑
巴扎黑Original
2017-05-20 14:13:452046browse

mysqlCreate user account

To create a new user account, use the CREATE USER statement, as follows:

Enter:

create user ben identified by 'p@$$w0rd';

Analysis: CREATE USER creates a new user account. A password is not necessarily required when creating a user account, but this example gives one using IDENTIFIED BY 'p@$$wOrd'. If you list the user accounts again, you will see the new accounts in the output.

Specify the hashed password IDENTIFIED BY The specified password is plain text, and MySQL will encrypt it before saving it to the user table. To specify a password as a hash value, use IDENTIFIED BY PASSWORD.

User accounts can also be created using the GRANT or INSERT GRANT statements (described later), but generally CREATE USER is the clearest and simplest statement. In addition, you can also add users by directly inserting rows into the user table, but for security reasons, this is generally not recommended. The tables (and table schemas, etc.) used by MySQL to store user account information are extremely important, and any damage to them may seriously harm the MySQL server. Therefore, it is better to use tags and functions to process these tables than to process them directly.

To rename a user account, use the RENAME USER statement, as follows:

Input:

rename user ben to bforta;

Before MySQL 5, only MySQL 5 or later versions supported RENAME USER. . To rename a user in previous MySQL, use UPDATE to directly update the user table.

mysql delete user account

In order to delete a user account (and related permissions), use the DROP USER statement, as shown below:

Enter :

drop user bforta;

Before MySQL 5 Since MySQL 5, DROP USER deletes the user account and all related account permissions. Before MySQL 5, DROP USER could only be used to delete user accounts, but not related permissions. Therefore, if you use an older version of MySQL, you need to first use REVOKE to delete the permissions related to the account, and then use DROP USER to delete the account.

【Related recommendations】

Mysql free video tutorial

2.

Command line example operations for mysql user management and password change

3.

Several points to note about mysql access control

4.

MySQL character set and collation order tutorial

5.

Introduction to MySQL character set and collation order

The above is the detailed content of MySQL creates user accounts and deletes user accounts. 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