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';