Create / Drop User Account in MySQL

Create / Drop / List the user account in MySQL database

List the User Account in MySQL Database

mysql> SELECT user, host FROM mysql.user;

+------------------+-----------+
| user             | host      |
+------------------+-----------+
| HR               | %         |
| user_admin       | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+

Create user account in MySQL Database

Syntax:
CREATE USER [IF NOT EXISTS] account_name
 IDENTIFIED BY 'password';

Example:
create user sales@localhost identified by 'Password!1';

Drop user account in MySQL Database

Syntax:
DROP USER '<user>'@'<host>';

Example:
DROP USER 'sales'@'localhost';

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.