{"id":151855,"date":"2024-11-01T18:03:19","date_gmt":"2024-11-01T10:03:19","guid":{"rendered":"https:\/\/server.hk\/cnblog\/151855\/"},"modified":"2024-11-01T18:03:20","modified_gmt":"2024-11-01T10:03:20","slug":"%e4%bf%9d%e8%ad%b7%e9%9a%b1%e7%a7%81%e5%ae%89%e5%85%a8%e5%ad%98%e5%84%b2-%e5%af%a6%e7%8f%be%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ad%97%e6%ae%b5%e7%9a%84mysql%e8%84%ab%e6%95%8f%e6%8a%80","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/151855\/","title":{"rendered":"\u4fdd\u8b77\u96b1\u79c1\u5b89\u5168\u5b58\u5132\u2014\u2014\u5be6\u73fe\u6578\u64da\u5eab\u5b57\u6bb5\u7684MySQL\u812b\u654f\u6280\u8853 (\u6578\u64da\u5eab\u5b57\u6bb5mysql\u812b\u654f)"},"content":{"rendered":"<h1 id=\"%e4%bf%9d%e8%ad%b7%e9%9a%b1%e7%a7%81%e5%ae%89%e5%85%a8%e5%ad%98%e5%84%b2-%e5%af%a6%e7%8f%be%e6%95%b8%e6%93%9a%e5%ba%ab%e5%ad%97%e6%ae%b5%e7%9a%84mysql%e8%84%ab%e6%95%8f%e6%8a%80-ATyrZYpoik\">\u4fdd\u8b77\u96b1\u79c1\u5b89\u5168\u5b58\u5132\u2014\u2014\u5be6\u73fe\u6578\u64da\u5eab\u5b57\u6bb5\u7684MySQL\u812b\u654f\u6280\u8853<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u5b57\u5316\u7684\u6642\u4ee3\uff0c\u6578\u64da\u96b1\u79c1\u548c\u5b89\u5168\u6027\u6210\u70ba\u4e86\u4f01\u696d\u548c\u500b\u4eba\u6700\u95dc\u6ce8\u7684\u554f\u984c\u4e4b\u4e00\u3002\u96a8\u8457\u6578\u64da\u6cc4\u9732\u4e8b\u4ef6\u7684\u983b\u7e41\u767c\u751f\uff0c\u5982\u4f55\u6709\u6548\u5730\u4fdd\u8b77\u654f\u611f\u6578\u64da\u6210\u70ba\u4e86\u4e9f\u5f85\u89e3\u6c7a\u7684\u6311\u6230\u3002MySQL\u4f5c\u70ba\u4e00\u7a2e\u5ee3\u6cdb\u4f7f\u7528\u7684\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u65b9\u6cd5\u4f86\u5be6\u73fe\u6578\u64da\u7684\u812b\u654f\u8655\u7406\uff0c\u5f9e\u800c\u4fdd\u8b77\u7528\u6236\u7684\u96b1\u79c1\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e6%95%b8%e6%93%9a%e8%84%ab%e6%95%8f%ef%bc%9f-ATyrZYpoik\">\u4ec0\u9ebc\u662f\u6578\u64da\u812b\u654f\uff1f<\/h2>\n<p>\u6578\u64da\u812b\u654f\u662f\u6307\u5c0d\u654f\u611f\u6578\u64da\u9032\u884c\u8655\u7406\uff0c\u4f7f\u5176\u5728\u4e0d\u5f71\u97ff\u6578\u64da\u4f7f\u7528\u7684\u60c5\u6cc1\u4e0b\uff0c\u7121\u6cd5\u88ab\u672a\u6388\u6b0a\u7684\u7528\u6236\u8b58\u5225\u6216\u9084\u539f\u3002\u9019\u4e00\u6280\u8853\u901a\u5e38\u61c9\u7528\u65bc\u91d1\u878d\u3001\u91ab\u7642\u3001\u96fb\u5b50\u5546\u52d9\u7b49\u884c\u696d\uff0c\u4ee5\u4fdd\u8b77\u7528\u6236\u7684\u500b\u4eba\u4fe1\u606f\u548c\u5546\u696d\u6a5f\u5bc6\u3002<\/p>\n<h2 id=\"mysql%e4%b8%ad%e7%9a%84%e8%84%ab%e6%95%8f%e6%8a%80%e8%a1%93-ATyrZYpoik\">MySQL\u4e2d\u7684\u812b\u654f\u6280\u8853<\/h2>\n<p>\u5728MySQL\u4e2d\uff0c\u5be6\u73fe\u6578\u64da\u812b\u654f\u7684\u65b9\u5f0f\u6709\u591a\u7a2e\uff0c\u4ee5\u4e0b\u662f\u5e7e\u7a2e\u5e38\u898b\u7684\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"1-%e6%95%b8%e6%93%9a%e5%8a%a0%e5%af%86-ATyrZYpoik\">1. \u6578\u64da\u52a0\u5bc6<\/h3>\n<p>\u6578\u64da\u52a0\u5bc6\u662f\u6700\u5e38\u898b\u7684\u812b\u654f\u6280\u8853\u4e4b\u4e00\u3002\u901a\u904e\u5c0d\u654f\u611f\u6578\u64da\u9032\u884c\u52a0\u5bc6\uff0c\u5373\u4f7f\u6578\u64da\u88ab\u975e\u6cd5\u8a2a\u554f\uff0c\u653b\u64ca\u8005\u4e5f\u7121\u6cd5\u89e3\u8b80\u5176\u5167\u5bb9\u3002MySQL\u63d0\u4f9b\u4e86\u591a\u7a2e\u52a0\u5bc6\u51fd\u6578\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre><code>SELECT AES_ENCRYPT('\u654f\u611f\u6578\u64da', '\u5bc6\u9470') AS encrypted_data;<\/code><\/pre>\n<p>\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\uff0c\u4f7f\u7528AES\u7b97\u6cd5\u5c0d\u654f\u611f\u6578\u64da\u9032\u884c\u52a0\u5bc6\uff0c\u4e26\u4f7f\u7528\u5bc6\u9470\u4f86\u4fdd\u8b77\u6578\u64da\u7684\u5b89\u5168\u6027\u3002<\/p>\n<h3 id=\"2-%e6%95%b8%e6%93%9a%e6%8e%a9%e7%a2%bc-ATyrZYpoik\">2. \u6578\u64da\u63a9\u78bc<\/h3>\n<p>\u6578\u64da\u63a9\u78bc\u662f\u53e6\u4e00\u7a2e\u6709\u6548\u7684\u812b\u654f\u6280\u8853\u3002\u901a\u904e\u5c07\u654f\u611f\u6578\u64da\u66ff\u63db\u70ba\u7121\u6cd5\u8b58\u5225\u7684\u5b57\u7b26\u6216\u7b26\u865f\uff0c\u4f86\u4fdd\u8b77\u6578\u64da\u7684\u96b1\u79c1\u3002\u4f8b\u5982\uff0c\u5c0d\u65bc\u4fe1\u7528\u5361\u865f\u78bc\uff0c\u53ef\u4ee5\u5c07\u5176\u986f\u793a\u70ba\uff1a<\/p>\n<pre><code>SELECT CONCAT('**** **** **** ', RIGHT(credit_card_number, 4)) AS masked_card_number FROM users;<\/code><\/pre>\n<p>\u9019\u6a23\uff0c\u53ea\u6709\u6700\u5f8c\u56db\u4f4d\u6578\u5b57\u53ef\u898b\uff0c\u5176\u4ed6\u90e8\u5206\u5247\u88ab\u63a9\u84cb\u3002<\/p>\n<h3 id=\"3-%e6%95%b8%e6%93%9a%e9%9a%a8%e6%a9%9f%e5%8c%96-ATyrZYpoik\">3. \u6578\u64da\u96a8\u6a5f\u5316<\/h3>\n<p>\u6578\u64da\u96a8\u6a5f\u5316\u662f\u6307\u5c07\u654f\u611f\u6578\u64da\u66ff\u63db\u70ba\u96a8\u6a5f\u751f\u6210\u7684\u6578\u64da\uff0c\u9019\u6a23\u5373\u4f7f\u6578\u64da\u88ab\u6cc4\u9732\uff0c\u4e5f\u7121\u6cd5\u9084\u539f\u51fa\u539f\u59cb\u6578\u64da\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>UPDATE users SET email = CONCAT('user', FLOOR(RAND() * 10000), '@example.com');<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u6709\u6548\u5730\u4fdd\u8b77\u7528\u6236\u7684\u96fb\u5b50\u90f5\u4ef6\u5730\u5740\uff0c\u9632\u6b62\u5176\u88ab\u6feb\u7528\u3002<\/p>\n<h2 id=\"%e5%af%a6%e6%96%bd%e8%84%ab%e6%95%8f%e6%8a%80%e8%a1%93%e7%9a%84%e8%80%83%e9%87%8f-ATyrZYpoik\">\u5be6\u65bd\u812b\u654f\u6280\u8853\u7684\u8003\u91cf<\/h2>\n<p>\u5728\u5be6\u65bdMySQL\u6578\u64da\u812b\u654f\u6280\u8853\u6642\uff0c\u4f01\u696d\u9700\u8981\u8003\u616e\u4ee5\u4e0b\u5e7e\u500b\u65b9\u9762\uff1a<\/p>\n<ul>\n<li><strong>\u5408\u898f\u6027\uff1a<\/strong>\u78ba\u4fdd\u9075\u5faa\u76f8\u95dc\u6cd5\u5f8b\u6cd5\u898f\uff0c\u5982GDPR\u6216CCPA\uff0c\u4ee5\u4fdd\u8b77\u7528\u6236\u7684\u96b1\u79c1\u3002<\/li>\n<li><strong>\u6027\u80fd\u5f71\u97ff\uff1a<\/strong>\u812b\u654f\u6280\u8853\u53ef\u80fd\u6703\u5f71\u97ff\u6578\u64da\u5eab\u7684\u6027\u80fd\uff0c\u56e0\u6b64\u9700\u8981\u9032\u884c\u6027\u80fd\u6e2c\u8a66\u3002<\/li>\n<li><strong>\u6578\u64da\u6062\u5fa9\uff1a<\/strong>\u5728\u9700\u8981\u6642\uff0c\u78ba\u4fdd\u80fd\u5920\u5b89\u5168\u5730\u6062\u5fa9\u539f\u59cb\u6578\u64da\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-ATyrZYpoik\">\u7d50\u8ad6<\/h2>\n<p>\u96a8\u8457\u6578\u64da\u96b1\u79c1\u554f\u984c\u7684\u65e5\u76ca\u56b4\u91cd\uff0c\u4f01\u696d\u5fc5\u9808\u63a1\u53d6\u6709\u6548\u7684\u63aa\u65bd\u4f86\u4fdd\u8b77\u654f\u611f\u6578\u64da\u3002MySQL\u63d0\u4f9b\u7684\u812b\u654f\u6280\u8853\uff0c\u5982\u6578\u64da\u52a0\u5bc6\u3001\u6578\u64da\u63a9\u78bc\u548c\u6578\u64da\u96a8\u6a5f\u5316\uff0c\u90fd\u662f\u5be6\u73fe\u6578\u64da\u4fdd\u8b77\u7684\u91cd\u8981\u624b\u6bb5\u3002\u901a\u904e\u5408\u7406\u7684\u5be6\u65bd\u9019\u4e9b\u6280\u8853\uff0c\u4f01\u696d\u4e0d\u50c5\u80fd\u5920\u4fdd\u8b77\u7528\u6236\u7684\u96b1\u79c1\uff0c\u9084\u80fd\u589e\u5f37\u7528\u6236\u5c0d\u54c1\u724c\u7684\u4fe1\u4efb\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc\u6578\u64da\u5b89\u5168\u548c\u5b58\u5132\u89e3\u6c7a\u65b9\u6848\u7684\u4fe1\u606f\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\uff0c\u63a2\u7d22\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u548c <a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a> \u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22MySQL\u812b\u654f\u6280\u8853\uff0c\u4fdd\u8b77\u96b1\u79c1\u5b89\u5168\u5b58\u5132\uff0c\u5be6\u73fe\u6578\u64da\u5eab\u5b57\u6bb5\u7684\u6578\u64da\u4fdd\u8b77\u8207\u96b1\u79c1\u5b89\u5168\u7ba1\u7406\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-151855","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/151855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=151855"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/151855\/revisions"}],"predecessor-version":[{"id":151856,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/151855\/revisions\/151856"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=151855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=151855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=151855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}