If we omit the hostname part of the user account, MySQL will accept it and allow the user to connect from any host. Its syntax would be as follows −
Use mysql; CREATE USER user_name IDENTIFIED BY password;
Here,
In the given example we are creating a user ‘REMOTE’ by omitting the host name.
mysql> CREATE USER remote identified by 'password123'; Query OK, 0 rows affected (0.00 sec)
The user ‘Remote’ can connect to a server by any host.
mysql> SHOW GRANTS FOR remote@'%'; +------------------------------------+ | Grants for remote@% | +------------------------------------+ | GRANT USAGE ON *.* TO 'remote'@'%' | +------------------------------------+ 1 row in set (0.00 sec)
The user can be created by omitting host name as well as password. It can be understood with the help of the following example in which we have created the user ‘hello’
mysql> Create user hello; Query OK, 0 rows affected (0.00 sec) mysql> show grants for hello@'%'; +-----------------------------------+ | Grants for hello@% | +-----------------------------------+ | GRANT USAGE ON *.* TO 'hello'@'%' | +-----------------------------------+ 1 row in set (0.00 sec)