How to create User in Mysql?



How to create User in Mysql

Create new user in Mysql

We can create MySQL accounts in two ways, By using statements such as Create user and Grant.
1.CREATE USER
Syntax
CREATE USER 'user_name'@ 'host_name' [IDENTIFIED BY [PASSWORD] 'password']
Example
CREATE USER 'senthil'@ 'localhost' identified by 'admin';
Note

It must be noted that CREATE USER command was added in the MySQL version 5.0.2. In earlier versions, users could be created automatically when assigning permissions using the GRANT command or by manually inserting records in the mysql database.
2.Grant User
Syntax
GRANT [PRIVILIAGES] ON 'database_name'.'table_name' TO ''user_name'@ ''host_name' IDENTIFIED BY 'password';
Example
GRANT ALL ON 'test'.* TO ''senthil'@ ''localhost' IDENTIFIED BY 'admin';

To see a list of the userd and their privileges.

use mysql;
select * from mysql.user where User='user' \G;