{"id":8622,"date":"2022-01-18T16:33:36","date_gmt":"2022-01-18T08:33:36","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=8622"},"modified":"2023-04-23T10:47:15","modified_gmt":"2023-04-23T02:47:15","slug":"gbase-8a%e7%9a%84%e5%9f%ba%e4%ba%8e%e4%b8%bb%e6%9c%ba%e7%9a%84%e7%99%bd%e5%90%8d%e5%8d%95%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/8622","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u57fa\u4e8e\u4e3b\u673aIP\u7684\u7528\u6237\u767d\u540d\u5355(allowlist)\u529f\u80fd"},"content":{"rendered":"<p>GBase 8a\u5728\u521b\u5efa\u7528\u6237\u4ee5\u53ca\u6388\u6743\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u8be5\u7528\u6237\u7684\u4e3b\u673aIP\uff0c\u53ea\u6709\u8be5IP\u624d\u53ef\u4ee5\u901a\u8fc7\u8be5\u7528\u6237\u8fdb\u884c\u8fde\u63a5\u548c\u64cd\u4f5c\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u4e3b\u673a\u767d\u540d\u5355\u529f\u80fd\u3002<\/p>\n\n\n\n<p>\u6ce8\u610f\u672c\u673a\u662flocalhost,\u5982\u679c\u4e0d\u6388\u6743\u7684\u8bdd\uff0c\u9ed8\u8ba4\u5c31\u5fc5\u987b\u6307\u5b9aIP\u6765\u8fde\u63a5\u672c\u673a\u3002 \u5176\u4e2d\u4e3b\u673a\u540d%\u8868\u793a\u6240\u6709\u7684IP\uff0c\u652f\u6301\u5339\u914d\u3002<\/p>\n\n\n\n<p>\u767d\u540d\u5355\uff0c\u662f\u6307\u5728\u73b0\u6709\u7528\u6237\u540d\u3010\u5141\u8bb8\u8fde\u63a5\u3011\u7684\u8303\u56f4\u4e0e\u767d\u540d\u5355\u7684\u3010\u4ea4\u96c6\u3011\u3002\u6bd4\u5982\u9ed8\u8ba4\u5141\u8bb8%\u6240\u6709IP,\u52a0\u767d\u540d\u5355\uff0c\u5219\u5c06\u53ea\u5141\u8bb8\u767d\u540d\u5355\u5185\u7684IP\u53ef\u4ee5\u8fde\u63a5\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u7528\u6237\u540d\u9ed8\u8ba4\u5141\u8bb8@'X.X.X.12%'\uff0c \u5982\u679c\u767d\u540d\u5355\u662f'X.X.X.13X', \u90a3\u4e48\u4ea4\u96c6\u4e3a\u7a7a\uff0c\u9020\u6210\u4efb\u4f55IP\u90fd\u65e0\u6cd5\u767b\u5f55\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2ad3e5492dc\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2ad3e5492dc\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E5%8F%82%E8%80%83\" >\u53c2\u8003<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E9%80%9A%E8%BF%87create_user%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7\" >\u901a\u8fc7create user\u521b\u5efa\u7528\u6237<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E9%80%9A%E8%BF%87grant%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7\" >\u901a\u8fc7grant\u521b\u5efa\u7528\u6237<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E9%80%9A%E8%BF%87user%E7%9A%84hosts%E5%8A%9F%E8%83%BD\" >\u901a\u8fc7user\u7684hosts\u529f\u80fd<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E8%BF%9E%E6%8E%A5%E6%B5%8B%E8%AF%95\" >\u8fde\u63a5\u6d4b\u8bd5<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E7%99%BD%E5%90%8D%E5%8D%95%E5%86%85%E7%9A%84IP%E8%BF%9E%E6%8E%A5\" >\u767d\u540d\u5355\u5185\u7684IP\u8fde\u63a5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.gbase8.cn\/en\/8622\/#%E5%85%B6%E5%AE%83IP%E8%BF%9E%E6%8E%A5\" >\u5176\u5b83IP\u8fde\u63a5<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%8F%82%E8%80%83\"><\/span>\u53c2\u8003<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/www.gbase8.cn\/en\/467\/?hilite=user+hosts\">GBase 8a\u96c6\u7fa4\u521b\u5efa\u7528\u6237create&nbsp;<mark>user<\/mark>\u5b8c\u6574\u8bed\u6cd5<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%80%9A%E8%BF%87create_user%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7\"><\/span>\u901a\u8fc7create user\u521b\u5efa\u7528\u6237<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; create user testdb2@10.0.2.101 identified by 'testdb2';\nQuery OK, 0 rows affected (Elapsed: 00:00:00.05)\n<\/code><\/pre>\n\n\n\n<p>\u652f\u6301\u6a21\u7cca\u5339\u914d<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; create user testdb@'10.0.2.%' identified by 'testdb';\nQuery OK, 0 rows affected (Elapsed: 00:00:00.03)\n\ngbase&gt; select trim(user),trim(host) from gbase.user;\n+------------+------------+\n| trim(user) | trim(host) |\n+------------+------------+\n| ab         | %          |\n| gbase      | %          |\n| root       | %          |\n| testdb     | 10.0.2.%   |\n+------------+------------+\n4 rows in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%80%9A%E8%BF%87grant%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7\"><\/span>\u901a\u8fc7grant\u521b\u5efa\u7528\u6237<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; select trim(user),trim(host) from gbase.user;\n+------------+------------+\n| trim(user) | trim(host) |\n+------------+------------+\n| ab         | %          |\n| gbase      | %          |\n| root       | %          |\n+------------+------------+\n3 rows in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<p>\u521b\u5efa\u7528\u6237<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; grant all on testdb.* to testdb@10.0.2.115 identified by 'testdb';\nQuery OK, 0 rows affected (Elapsed: 00:00:00.04)\n\ngbase&gt; select trim(user),trim(host) from gbase.user;\n+------------+------------+\n| trim(user) | trim(host) |\n+------------+------------+\n| ab         | %          |\n| gbase      | %          |\n| root       | %          |\n| testdb     | 10.0.2.115 |\n+------------+------------+\n4 rows in set (Elapsed: 00:00:00.00)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E9%80%9A%E8%BF%87user%E7%9A%84hosts%E5%8A%9F%E8%83%BD\"><\/span>\u901a\u8fc7user\u7684hosts\u529f\u80fd<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u6570\u636e\u5e93\u7528\u6237\u6709\u4e2ahosts\u53c2\u6570\uff0c\u53ef\u4ee5\u901a\u8fc7create \/alter user\u65f6\u6307\u5b9a\u3002 \u53ef\u4ee5\u53c2\u8003 <a href=\"https:\/\/www.gbase8.cn\/en\/467\/?hilite=user+hosts\">GBase 8a\u96c6\u7fa4\u521b\u5efa\u7528\u6237create\u00a0<mark>user<\/mark>\u5b8c\u6574\u8bed\u6cd5<\/a><\/p>\n\n\n\n<p>\u5982\u4e0b\u662f\u7ed9\u9ed8\u8ba4%\u7684\u7528\u6237\u8bbe\u7f6e\u767d\u540d\u5355<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>gbase&gt; alter user user1 hosts '10.0.2.18%';\nQuery OK, 0 rows affected (Elapsed: 00:00:00.02)\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li>\u9ed8\u8ba4hosts\u4e3a\u7a7a\uff0c\u4e0d\u9650\u5236<\/li><li>\u591a\u4e2ahost\u7528\u7a7a\u683c\u5206\u5272<\/li><li>host\u7684IP\u5217\u8868\u53ef\u4ee5\u7528%\u548c_\u505a\u901a\u914d\u7b26\uff0c\u4e0elike\u76f8\u540c<\/li><\/ul>\n\n\n\n<p>\u5982\u679c\u662f\u7ed9\u5df2\u7ecf\u5b58\u5728IP\u9650\u5236\u7684\u7528\u6237(user1@'10.0.2.18%'\uff09\u8bbe\u7f6e\u767d\u540d\u5355\uff0c\u9700\u8981\u6ce8\u610fIP\u7684\u4ea4\u96c6\u3002<\/p>\n\n\n\n<p>\u8be5\u4fe1\u606f\u53ef\u6709\u4eceuser_check\u8868\u7684hostlist\u91cc\u67e5\u8be2\u5230\uff0c\u9ed8\u8ba4\u957f\u5ea65000\u5b57\u7b26\u3002 <a href=\"https:\/\/www.gbase8.cn\/en\/4698\/?hilite=user_check\">GBase 8a\u7528\u6237\u5b89\u5168\u7b56\u7565\u5143\u6570\u636e\u8868<mark>user_check<\/mark>\u4ecb\u7ecd<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%BF%9E%E6%8E%A5%E6%B5%8B%E8%AF%95\"><\/span>\u8fde\u63a5\u6d4b\u8bd5<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%99%BD%E5%90%8D%E5%8D%95%E5%86%85%E7%9A%84IP%E8%BF%9E%E6%8E%A5\"><\/span>\u767d\u540d\u5355\u5185\u7684IP\u8fde\u63a5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;gbase@gbase_rh7_015 ~]$ ip addr\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN qlen 1\n    link\/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00\n    inet 127.0.0.1\/8 scope host lo\n       valid_lft forever preferred_lft forever\n    inet6 ::1\/128 scope host\n       valid_lft forever preferred_lft forever\n2: enp0s3: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc pfifo_fast state UP qlen 1000\n    link\/ether 08:00:27:db:02:33 brd ff:ff:ff:ff:ff:ff\n    inet 10.0.2.115\/24 brd 10.0.2.255 scope global enp0s3\n       valid_lft forever preferred_lft forever\n    inet6 fe80::8b26:63ff:c505:191c\/64 scope link\n       valid_lft forever preferred_lft forever\n3: virbr0: &lt;NO-CARRIER,BROADCAST,MULTICAST,UP&gt; mtu 1500 qdisc noqueue state DOWN qlen 1000\n    link\/ether 52:54:00:4a:d6:8a brd ff:ff:ff:ff:ff:ff\n    inet 192.168.122.1\/24 brd 192.168.122.255 scope global virbr0\n       valid_lft forever preferred_lft forever\n4: virbr0-nic: &lt;BROADCAST,MULTICAST&gt; mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000\n    link\/ether 52:54:00:4a:d6:8a brd ff:ff:ff:ff:ff:ff\n&#91;gbase@gbase_rh7_015 ~]$ gccli -utestdb -ptestdb -h10.0.2.101\n\nGBase client 9.5.2.43.5f8fd4b2. Copyright (c) 2004-2022, GBase.  All Rights Reserved.\n\ngbase&gt; ^CAborted\n&#91;gbase@gbase_rh7_015 ~]$\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%85%B6%E5%AE%83IP%E8%BF%9E%E6%8E%A5\"><\/span>\u5176\u5b83IP\u8fde\u63a5<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u62a5\u627e\u4e0d\u5230\u5bf9\u5e94\u7528\u6237\u7684\u9519\u8bef<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;gbase@gbase_rh7_001 ~]$ gccli -utestdb -ptestdb\nERROR 1133 (42000): Can't find any matching row in the user table\n&#91;gbase@gbase_rh7_001 ~]$ gccli -utestdb -ptestdb -h10.0.2.101\nERROR 1133 (42000): Can't find any matching row in the user table\n&#91;gbase@gbase_rh7_001 ~]$\n<\/code><\/pre>\n\n\n\n<p>IP\u88ab\u9650\u5236<\/p>\n\n\n\n<pre class=\"wp-block-code has-small-font-size\"><code>&#91;gbase@gbase_rh7_015 ~]$ gccli -uuser1 -pp2resu\nERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this GBase server\n&#91;gbase@gbase_rh7_015 ~]$ gccli -uuser1 -pp2resu -h10.0.2.115\nERROR 1130 (HY000): Host '10.0.2.115' is not allowed to connect to this GBase server\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u5728\u521b\u5efa\u7528\u6237\u4ee5\u53ca\u6388\u6743\u65f6\uff0c\u53ef\u4ee5\u6307\u5b9a\u8be5\u7528\u6237\u7684\u4e3b\u673aIP\uff0c\u53ea\u6709\u8be5IP\u624d\u53ef\u4ee5\u901a\u8fc7\u8be5\u7528\u6237\u8fdb\u884c\u8fde\u63a5\u548c\u64cd\u4f5c\uff0c\u4ece\u800c\u5b9e\u73b0\u4e86\u4e3b\u673a\u767d\u540d\u5355\u529f\u80fd\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[76],"class_list":["post-8622","post","type-post","status-publish","format-standard","hentry","category-gbase8a","tag-76"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/8622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=8622"}],"version-history":[{"count":24,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/8622\/revisions"}],"predecessor-version":[{"id":11670,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/8622\/revisions\/11670"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=8622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=8622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=8622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}