Skip to content

How to create new user in MySQL

% = wildcard (any)

Create a new Super-User “GURU”

GRANT ALL PRIVILEGES ON *.* TO ‘GURU’@’%’ IDENTIFIED BY ‘abc123’ WITH GRANT OPTION;

(root@localhost) [mysql]> select user,host,password from user;
+———+———–+——————————–
| user    | host      | password                                  |
+———+———–+———————————-
| root    | localhost | *6691484EA6B50DDDE1926A220 |
| root    | suse01    | *6691484EA6B50DDDE1926A22|
| replica | %         | *6691484EA6B50DDDE1926A220|
| GURU    | %         | *6691484EA6B50DDDE1926A220|
+———+———–+———————————
4 rows in set (0.00 sec)

we can test the remote connectivity!!

debian4:/home/kraneis# mysql -u GURU -h suse01 -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.67-community-log MySQL Community Edition (GPL)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> select current_user();
+—————-+
| current_user() |
+—————-+
| GURU@% |
+—————-+
1 row in set (0.01 sec)

mysql> show grants;
+——————————————————————————————————————————–+
| Grants for GURU@%                                                                                                              |
+——————————————————————————————————————————–+
| GRANT ALL PRIVILEGES ON *.* TO ‘GURU’@’%’ IDENTIFIED BY PASSWORD ‘*CA57CBD0790575D1668CC58E7ECB5D23A8C77608’ WITH GRANT OPTION |
+——————————————————————————————————————————–+
1 row in set (0.00 sec)

mysql>