Accout creation, deletion, permission granting
Let's check account information in MySQL.
Accout creation, deletion, permission granting
Account creation and deletion, permission granting
- Account creation and deletion
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- Add a user that allows external access.
create user 'user_id'@'%' identified by 'passwd';
drop user 'user_id';
-- Add a user that allows internal access.
create user 'user_id'@'localhost' identified by 'passwd';
drop user 'user_id';
-- Add a user that allows access only from a specific IP
create user 'user_id'@'123.456.789.100' identified by 'passwd';
drop user 'user_id';
-- Add a user that allows access from a specific IP range
create user 'user_id'@'192.168.%' identified by 'passwd';
drop user 'user_id';
- Account permission granting
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- Grant all privileges on all tables of all databases.
grant all privileges on *.* to 'user_id'@'%';
flush privileges;
-- Grant all privileges on all tables of a specific database.
grant all privileges on 'db_name'.* to 'userid'@'%';
flush privileges;
-- Grant all privileges on a specific table of a specific database.
grant all privileges on 'db_name'.'table_name' to 'userid'@'%';
flush privileges;
-- Grant `SELECT` and `INSERT` privileges on a specific table of a specific database.
grant select, insert on 'db_name'.'table_name' to 'userid'@'%';
flush privileges;
-- Grant `UPDATE` privileges on `column1` and `column2` of a specific table in a specific database.
grant update(column1, column2) on 'db_name'.'table_name' to 'userid'@'%';
flush privileges;
This post is licensed under CC BY 4.0 by the author.