

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we create a MySQL user account by omitting the hostname?
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,
- user_name is the name of the user we wish to take account of.
- Password is the password we wish to make for user_account. With the help of this password, MySQL server will identify this user.
Example
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)
- Related Questions & Answers
- How can we set up a MySQL User account by using INSERT INTO statement?
- How can we set up a MySQL User account by using SQL GRANT statement?
- How can we change MySQL user password by using the ALTER USER statement?
- How can we create user accounts in MySQL database server?
- How can we change MySQL user password by using UPDATE statement?
- How can we change MySQL user password by using the SET PASSWORD statement?
- How can we grant privileges to a MySQL user?
- How can we revoke privileges from a MySQL user?
- How can we create the MySQL view with ORDER BY clause?
- How can we create a MySQL table by using PHP script?
- How can we create a MySQL view with GROUP BY clause?
- In MySQL, how can we display time in other format specified by the user?
- In MySQL, how can we display the date in other format specified by the user?
- Can we use the word user for a MySQL table?
- How can we create a MySQL temporary table by using PHP script?
Advertisements