{"id":95,"date":"2023-05-25T15:40:37","date_gmt":"2023-05-25T07:40:37","guid":{"rendered":"https:\/\/jiachen.de.cool\/blog\/?p=95"},"modified":"2023-05-25T15:42:45","modified_gmt":"2023-05-25T07:42:45","slug":"%e6%95%b0%e6%8d%ae%e6%8e%a7%e5%88%b6%e8%af%ad%e8%a8%80dcl","status":"publish","type":"post","link":"https:\/\/jiachen.de.cool\/blog\/2023\/05\/25\/%e6%95%b0%e6%8d%ae%e6%8e%a7%e5%88%b6%e8%af%ad%e8%a8%80dcl\/","title":{"rendered":"\u6570\u636e\u63a7\u5236\u8bed\u8a00DCL"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Data Control Language \u7528\u6765\u6388\u4e88\u6216\u56de\u6536\u8bbf\u95ee\u6570\u636e\u5e93\u7684\u67d0\u79cd\u7279\u6743\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mysql&gt; create user jiachen@'%' identified by '123';\/*\u521b\u5efa\u7528\u6237*\/\nQuery OK, 0 rows affected (0.02 sec)\n\nmysql&gt; show grants for jiachen;\n+-------------------------------------+\n| Grants for jiachen@%                |\n+-------------------------------------+\n| GRANT USAGE ON *.* TO `jiachen`@`%` |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql&gt; use learning3;\nDatabase changed\nmysql&gt; show tables;\n+---------------------+\n| Tables_in_learning3 |\n+---------------------+\n| test                |\n+---------------------+\n1 row in set (0.01 sec)\n\nmysql&gt; grant select,insert,update,delete on learning3.test to jiachen@'%';\/*\u8d4b\u4e88\u7528\u6237\u6240\u5217\u51fa\u7684\u5728\u7279\u5b9a\u6570\u636e\u5e93\u8868\u4e2d\u7684\u6743\u9650*\/\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql&gt; show grants for jiachen;\/*\u663e\u793a\u6743\u9650\u4fe1\u606f*\/\n+-----------------------------------------------------------------------------+\n| Grants for jiachen@%                                                        |\n+-----------------------------------------------------------------------------+\n| GRANT USAGE ON *.* TO `jiachen`@`%`                                         |\n| GRANT SELECT, INSERT, UPDATE, DELETE ON `learning3`.`test` TO `jiachen`@`%` |\n+-----------------------------------------------------------------------------+\n2 rows in set (0.00 sec)\n\nmysql&gt; grant all privileges on *.* to jiachen@'%';\/*\u8d4b\u4e88\u7528\u6237\u5168\u90e8\u6743\u9650*\/\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql&gt; flush privileges;\/*\u5237\u65b0\u6743\u9650*\/\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql&gt; show grants for jiachen;\n+-------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n----------+\n| Grants for jiachen@%\n\n\n\n\n          |\n+-------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n----------+\n| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS,\n FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES,\n LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW\nVIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESP\nACE, CREATE ROLE, DROP ROLE ON *.* TO `jiachen`@`%`\n          |\n| GRANT APPLICATION_PASSWORD_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_A\nDMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VA\nRIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,R\nOLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SYSTEM_US\nER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `jia\nchen`@`%` |\n| GRANT SELECT, INSERT, UPDATE, DELETE ON `learning3`.`test` TO `jiachen`@`%`\n\n\n\n\n          |\n+-------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n----------+\n3 rows in set (0.00 sec)\n\nmysql&gt; revoke select,insert,update,delete on learning3.test from jiachen@'%';\/*\u64a4\u9500\u6240\u5217\u6743\u9650*\/\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql&gt; show grants for jiachen;\n+-------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n----------+\n| Grants for jiachen@%\n\n\n\n\n          |\n+-------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n----------+\n| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS,\n FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES,\n LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW\nVIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESP\nACE, CREATE ROLE, DROP ROLE ON *.* TO `jiachen`@`%`\n          |\n| GRANT APPLICATION_PASSWORD_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_A\nDMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VA\nRIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,R\nOLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SYSTEM_US\nER,SYSTEM_VARIABLES_ADMIN,TABLE_ENCRYPTION_ADMIN,XA_RECOVER_ADMIN ON *.* TO `jia\nchen`@`%` |\n+-------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n--------------------------------------------------------------------------------\n----------+\n2 rows in set (0.00 sec)\n\nmysql&gt; revoke all privileges on *.* from jiachen@'%';\/*\u64a4\u9500\u7528\u6237\u5168\u90e8\u6743\u9650*\/\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql&gt; show grants for jiachen;\n+-------------------------------------+\n| Grants for jiachen@%                |\n+-------------------------------------+\n| GRANT USAGE ON *.* TO `jiachen`@`%` |\n+-------------------------------------+\n1 row in set (0.00 sec)\n\nmysql&gt; drop user jiachen;\/*\u5220\u9664\u7528\u6237*\/\nQuery OK, 0 rows affected (0.01 sec)\n\nmysql&gt; show variables like 'autocommit';\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | OFF   |\n+---------------+-------+\n1 row in set, 1 warning (0.01 sec)\n\nmysql&gt; set global autocommit='on';\/*\u8bbe\u7f6e\u6253\u5f00\u81ea\u52a8\u63d0\u4ea4*\/\nQuery OK, 0 rows affected (0.00 sec)\n\nmysql&gt; show variables like 'autocommit';\/*\u663e\u793a\u81ea\u52a8\u63d0\u4ea4\u4ecd\u4e3a\u5173\u95ed\u72b6\u6001*\/\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | OFF   |\n+---------------+-------+\n1 row in set, 1 warning (0.01 sec)\n\nmysql&gt; exit\nBye\n\n\nC:\\Windows\\system32&gt;mysql -u root -p\nEnter password: ******\nWelcome to the MySQL monitor.  Commands end with ; or \\g.\nYour MySQL connection id is 36\nServer version: 8.0.16 MySQL Community Server - GPL\n\nCopyright (c) 2000, 2019, Oracle and\/or its affiliates. All rights reserved.\n\nOracle is a registered trademark of Oracle Corporation and\/or its\naffiliates. Other names may be trademarks of their respective\nowners.\n\nType 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.\n\nmysql&gt; show variables like 'autocommit';\/*\u91cd\u65b0\u767b\u5f55\u540e\u81ea\u52a8\u63d0\u4ea4\u751f\u6548*\/\n+---------------+-------+\n| Variable_name | Value |\n+---------------+-------+\n| autocommit    | ON    |\n+---------------+-------+\n1 row in set, 1 warning (0.01 sec)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Data Control Language \u7528\u6765\u6388\u4e88\u6216\u56de\u6536\u8bbf\u95ee\u6570\u636e\u5e93\u7684\u67d0\u79cd\u7279\u6743\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[14,15],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-dcl","tag-15"],"_links":{"self":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":2,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":97,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions\/97"}],"wp:attachment":[{"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jiachen.de.cool\/blog\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}