Create MySQL user and grant permission
Here we learn, how to create MySQL user?
Suppose we want to create user Danish and want to full access on MySQL Databases/tables from any IP.
Syntax to create user:- CREATE USER '< user name >'@'< password >' IDENTIFIED BY
Syntax to grant permission:- GRANT < permission > ON < database >.< table > WITH GRANT OPTION
Following is an example of above.
CREATE USER 'danish'@'*' IDENTIFIED BY 'danish';
GRANT ALL PRIVILEGES ON student.login TO 'danish'@'*' WITH GRANT OPTION;
In above example we have created a user with name danish, this user can only access login table in student database and can perform all operations on login table.
You can assing a specific domain/ip for MySQL user danish to access MySQL. Find below.
CREATE USER 'danish'@'255.255.255.255' IDENTIFIED BY 'danish';
GRANT ALL PRIVILEGES ON student.login TO 'danish'@'255.255.255.255' WITH GRANT OPTION;
You can grant all database access with all tables. Find Below.
CREATE USER 'danish'@'255.255.255.255' IDENTIFIED BY 'danish';
GRANT ALL PRIVILEGES ON *.*TO 'danish'@'255.255.255.255' WITH GRANT OPTION;
Following are the privileges and their meaning in MySQL.
No comments:
Post a Comment