Skip to content

Commit e6d7d0e

Browse files
authored
Merge pull request #309 from GeoSegun/new-branch
Give All Permissions to a User in SQL
2 parents 6a624ce + de4bde8 commit e6d7d0e

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CREATE USER 'dev_user'@'%' IDENTIFIED BY 'password123';
2+
3+
GRANT ALL PRIVILEGES ON University.* TO 'dev_user'@'%';
4+
5+
SELECT GRANTEE, PRIVILEGE_TYPE
6+
FROM information_schema.user_privileges
7+
WHERE GRANTEE = "'dev_user'@'%'";
8+
9+
SHOW GRANTS FOR 'dev_user'@'%';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CREATE USER dev_user WITH PASSWORD 'password123';
2+
3+
SELECT grantee, privilege_type, table_schema, table_name
4+
FROM information_schema.role_table_grants
5+
WHERE grantee = 'dev_user';
6+
7+
GRANT CONNECT ON DATABASE university TO dev_user;
8+
9+
GRANT USAGE ON SCHEMA public TO dev_user;
10+
GRANT CREATE ON SCHEMA public TO dev_user;
11+
12+
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO dev_user;
13+
14+
GRANT USAGE, SELECT, UPDATE ON ALL SEQUENCES IN SCHEMA public TO dev_user;
15+
ALTER DEFAULT PRIVILEGES IN SCHEMA public
16+
GRANT USAGE, SELECT, UPDATE ON SEQUENCES TO dev_user;
17+
18+
SELECT grantee, privilege_type, table_schema, table_name
19+
FROM information_schema.role_table_grants
20+
WHERE grantee = 'dev_user';
21+
22+
select * from student limit 3;
23+

0 commit comments

Comments
 (0)