Jump to: navigation, search

Mysql CREATE USER

From w3cyberlearnings

Contents

MySQL CREATE USER Function

This function creates a new MySQL user account.

Syntax CREATE USER

  • user_abc: account name
  • host: host name
  • user_password: user password
CREATE USER user_abc@host IDENTIFIED BY user_password;

Example 1: Create user without password

To connect without password

mysql> CREATE USER 'kip1234'@'localhost';
Query OK, 0 rows affected (0.03 sec)

Example 2

Create user with a password


mysql> CREATE USER 'job1234'@'localhost' IDENTIFIED BY 'topsecret';
Query OK, 0 rows affected (0.00 sec)

Example 3:Create with a different hostname

  • Create two users with a different host name.
mysql> CREATE USER 'joby'@'abc.a31' IDENTIFIED BY 'job3332$pas';
Query OK, 0 rows affected (0.00 sec)

mysql> CREATE USER 'joby'@'10.8.4.21' IDENTIFIED BY 'job3332$pas';
Query OK, 0 rows affected (0.00 sec)

Example 4: List all users

mysql> SELECT host,user FROM mysql.user;
+----------------------+------------------+
| host                 | user             |
+----------------------+------------------+
| %                    | paul             | 
| 10.8.4.21            | joby             | 
| 127.0.0.1            | root             | 
| abc.a31              | joby             | 
| localhost            | debian-sys-maint | 
| localhost            | druapluser       | 
| localhost            | job123           | 
| localhost            | job1234          | 
| localhost            | john             | 
| localhost            | johnny           | 
| localhost            | kip1234          | 
| localhost            | kwan             | 
| localhost            | root             | 
| toyoma-PC            | bob              | 
| w3cyberlearnings.com | bob              | 
| wlith                | sophal           | 
+----------------------+------------------+
16 rows in set (0.00 sec)

Related Links


---CREATE USER--- DROP USER--- GRANT User Privilege--- RENAME USER--- REVOKE--- SET PASSWORD---


Navigation
Web
SQL
MISC
References