{"id":152217,"date":"2024-11-01T21:05:22","date_gmt":"2024-11-01T13:05:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/152217\/"},"modified":"2024-11-01T21:05:23","modified_gmt":"2024-11-01T13:05:23","slug":"%e4%b8%8d%e5%8f%af%e7%bc%ba%e5%b0%91%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e5%85%b1%e4%ba%ab%e6%8a%80%e8%a1%93-%e6%95%b8%e6%93%9a%e5%ba%ab%e5%85%b1%e5%bf%85","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/152217\/","title":{"rendered":"\u4e0d\u53ef\u7f3a\u5c11\u7684\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853 (\u6578\u64da\u5eab\u5171\u5fc5)"},"content":{"rendered":"<h1 id=\"%e4%b8%8d%e5%8f%af%e7%bc%ba%e5%b0%91%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e5%85%b1%e4%ba%ab%e6%8a%80%e8%a1%93-%e6%95%b8%e6%93%9a%e5%ba%ab%e5%85%b1%e5%bf%85-XxIhkApqOO\">\u4e0d\u53ef\u7f3a\u5c11\u7684\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853 (\u6578\u64da\u5eab\u5171\u5fc5)<\/h1>\n<p>\u5728\u7576\u4eca\u6578\u64da\u9a45\u52d5\u7684\u4e16\u754c\u4e2d\uff0c\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u5df2\u6210\u70ba\u4f01\u696d\u548c\u958b\u767c\u8005\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002\u96a8\u8457\u6578\u64da\u91cf\u7684\u6fc0\u589e\uff0c\u5982\u4f55\u6709\u6548\u5730\u7ba1\u7406\u548c\u5171\u4eab\u6578\u64da\u6210\u70ba\u4e86\u95dc\u9375\u554f\u984c\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u7684\u57fa\u672c\u6982\u5ff5\u3001\u4e3b\u8981\u985e\u578b\u53ca\u5176\u5728\u5be6\u969b\u61c9\u7528\u4e2d\u7684\u91cd\u8981\u6027\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af%e6%95%b8%e6%93%9a%e5%ba%ab%e5%85%b1%e4%ba%ab%e6%8a%80%e8%a1%93%ef%bc%9f-XxIhkApqOO\">\u4ec0\u9ebc\u662f\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\uff1f<\/h2>\n<p>\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u662f\u6307\u591a\u500b\u7528\u6236\u6216\u61c9\u7528\u7a0b\u5e8f\u80fd\u5920\u540c\u6642\u8a2a\u554f\u548c\u64cd\u4f5c\u540c\u4e00\u6578\u64da\u5eab\u7684\u80fd\u529b\u3002\u9019\u7a2e\u6280\u8853\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6578\u64da\u7684\u53ef\u7528\u6027\uff0c\u9084\u4fc3\u9032\u4e86\u5354\u4f5c\u548c\u6578\u64da\u7684\u5be6\u6642\u66f4\u65b0\u3002\u6578\u64da\u5eab\u5171\u4eab\u53ef\u4ee5\u5206\u70ba\u5169\u5927\u985e\uff1a\u96c6\u4e2d\u5f0f\u5171\u4eab\u548c\u5206\u6563\u5f0f\u5171\u4eab\u3002<\/p>\n<h3 id=\"%e9%9b%86%e4%b8%ad%e5%bc%8f%e5%85%b1%e4%ba%ab-XxIhkApqOO\">\u96c6\u4e2d\u5f0f\u5171\u4eab<\/h3>\n<p>\u5728\u96c6\u4e2d\u5f0f\u5171\u4eab\u4e2d\uff0c\u6240\u6709\u6578\u64da\u90fd\u5b58\u5132\u5728\u4e00\u500b\u4e2d\u592e\u6578\u64da\u5eab\u4e2d\uff0c\u6240\u6709\u7528\u6236\u901a\u904e\u7db2\u7d61\u8a2a\u554f\u9019\u500b\u6578\u64da\u5eab\u3002\u9019\u7a2e\u65b9\u5f0f\u7684\u512a\u9ede\u5728\u65bc\u6578\u64da\u7ba1\u7406\u7684\u96c6\u4e2d\u5316\uff0c\u4fbf\u65bc\u7dad\u8b77\u548c\u5099\u4efd\u3002\u4f8b\u5982\uff0c\u8a31\u591a\u4f01\u696d\u4f7f\u7528\u95dc\u4fc2\u578b\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff08RDBMS\uff09\u5982 MySQL \u6216 PostgreSQL \u4f86\u5be6\u73fe\u96c6\u4e2d\u5f0f\u6578\u64da\u5eab\u5171\u4eab\u3002<\/p>\n<pre><code>-- MySQL \u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u5171\u4eab\u6578\u64da\u5eab\nCREATE DATABASE shared_db;\nUSE shared_db;\n\nCREATE TABLE users (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    name VARCHAR(100),\n    email VARCHAR(100)\n);\n<\/code><\/pre>\n<h3 id=\"%e5%88%86%e6%95%a3%e5%bc%8f%e5%85%b1%e4%ba%ab-XxIhkApqOO\">\u5206\u6563\u5f0f\u5171\u4eab<\/h3>\n<p>\u5206\u6563\u5f0f\u5171\u4eab\u5247\u662f\u5c07\u6578\u64da\u5206\u6563\u5b58\u5132\u5728\u591a\u500b\u4f4d\u7f6e\uff0c\u9019\u6a23\u7528\u6236\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u5730\u9ede\u8a2a\u554f\u6578\u64da\u3002\u9019\u7a2e\u65b9\u5f0f\u901a\u5e38\u7528\u65bc\u5927\u898f\u6a21\u7684\u61c9\u7528\u7a0b\u5e8f\uff0c\u5982\u793e\u4ea4\u5a92\u9ad4\u5e73\u53f0\u548c\u96fb\u5b50\u5546\u52d9\u7db2\u7ad9\u3002\u5206\u6563\u5f0f\u6578\u64da\u5eab\u7cfb\u7d71\u5982 Cassandra \u548c MongoDB \u5141\u8a31\u7528\u6236\u5728\u591a\u500b\u4f3a\u670d\u5668\u4e0a\u5b58\u5132\u548c\u6aa2\u7d22\u6578\u64da\uff0c\u5f9e\u800c\u63d0\u9ad8\u4e86\u7cfb\u7d71\u7684\u53ef\u64f4\u5c55\u6027\u548c\u5bb9\u932f\u6027\u3002<\/p>\n<pre><code>\/\/ MongoDB \u793a\u4f8b\uff1a\u5275\u5efa\u4e00\u500b\u5171\u4eab\u96c6\u5408\nuse shared_db;\n\ndb.users.insertMany([\n    { name: \"Alice\", email: \"alice@example.com\" },\n    { name: \"Bob\", email: \"bob@example.com\" }\n]);\n<\/code><\/pre>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e5%85%b1%e4%ba%ab%e6%8a%80%e8%a1%93%e7%9a%84%e5%84%aa%e5%8b%a2-XxIhkApqOO\">\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u7684\u512a\u52e2<\/h2>\n<ul>\n<li><strong>\u63d0\u9ad8\u6548\u7387\uff1a<\/strong>\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u4f7f\u5f97\u591a\u500b\u7528\u6236\u53ef\u4ee5\u540c\u6642\u8a2a\u554f\u548c\u64cd\u4f5c\u6578\u64da\uff0c\u5f9e\u800c\u63d0\u9ad8\u4e86\u5de5\u4f5c\u6548\u7387\u3002<\/li>\n<li><strong>\u5be6\u6642\u66f4\u65b0\uff1a<\/strong>\u7528\u6236\u53ef\u4ee5\u5373\u6642\u770b\u5230\u6578\u64da\u7684\u8b8a\u66f4\uff0c\u9019\u5c0d\u65bc\u9700\u8981\u5feb\u901f\u53cd\u61c9\u7684\u696d\u52d9\u81f3\u95dc\u91cd\u8981\u3002<\/li>\n<li><strong>\u4fc3\u9032\u5354\u4f5c\uff1a<\/strong>\u5718\u968a\u6210\u54e1\u53ef\u4ee5\u5728\u540c\u4e00\u6578\u64da\u96c6\u4e0a\u5354\u4f5c\uff0c\u6e1b\u5c11\u4e86\u6578\u64da\u5b64\u5cf6\u7684\u554f\u984c\u3002<\/li>\n<li><strong>\u53ef\u64f4\u5c55\u6027\uff1a<\/strong>\u5206\u6563\u5f0f\u6578\u64da\u5eab\u7cfb\u7d71\u80fd\u5920\u96a8\u8457\u9700\u6c42\u7684\u589e\u9577\u800c\u64f4\u5c55\uff0c\u652f\u6301\u66f4\u5927\u7684\u6578\u64da\u91cf\u548c\u7528\u6236\u6578\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%af%a6%e9%9a%9b%e6%87%89%e7%94%a8%e6%a1%88%e4%be%8b-XxIhkApqOO\">\u5be6\u969b\u61c9\u7528\u6848\u4f8b<\/h2>\n<p>\u8a31\u591a\u884c\u696d\u90fd\u5728\u5229\u7528\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u4f86\u63d0\u5347\u696d\u52d9\u904b\u71df\u3002\u4f8b\u5982\uff0c\u96fb\u5b50\u5546\u52d9\u5e73\u53f0\u4f7f\u7528\u5171\u4eab\u6578\u64da\u5eab\u4f86\u7ba1\u7406\u7522\u54c1\u4fe1\u606f\u3001\u8a02\u55ae\u548c\u5ba2\u6236\u6578\u64da\u3002\u9019\u6a23\uff0c\u7121\u8ad6\u662f\u524d\u7aef\u7684\u7528\u6236\u754c\u9762\u9084\u662f\u5f8c\u7aef\u7684\u7ba1\u7406\u7cfb\u7d71\uff0c\u90fd\u80fd\u5920\u5373\u6642\u7372\u53d6\u6700\u65b0\u7684\u6578\u64da\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u91d1\u878d\u884c\u696d\u4e5f\u5ee3\u6cdb\u61c9\u7528\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u4f86\u9032\u884c\u4ea4\u6613\u8655\u7406\u548c\u98a8\u96aa\u7ba1\u7406\u3002\u901a\u904e\u5be6\u6642\u6578\u64da\u5171\u4eab\uff0c\u91d1\u878d\u6a5f\u69cb\u80fd\u5920\u66f4\u5feb\u5730\u505a\u51fa\u6c7a\u7b56\uff0c\u964d\u4f4e\u98a8\u96aa\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-XxIhkApqOO\">\u7d50\u8ad6<\/h2>\n<p>\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u5728\u73fe\u4ee3\u5546\u696d\u74b0\u5883\u4e2d\u626e\u6f14\u8457\u81f3\u95dc\u91cd\u8981\u7684\u89d2\u8272\u3002\u7121\u8ad6\u662f\u96c6\u4e2d\u5f0f\u9084\u662f\u5206\u6563\u5f0f\u7684\u6578\u64da\u5eab\u5171\u4eab\uff0c\u90fd\u80fd\u5920\u63d0\u9ad8\u6578\u64da\u7684\u53ef\u7528\u6027\u548c\u6548\u7387\uff0c\u4fc3\u9032\u5718\u968a\u5354\u4f5c\u3002\u96a8\u8457\u6280\u8853\u7684\u9032\u6b65\uff0c\u672a\u4f86\u7684\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u5c07\u6703\u66f4\u52a0\u667a\u80fd\u5316\u548c\u81ea\u52d5\u5316\uff0c\u70ba\u4f01\u696d\u5e36\u4f86\u66f4\u591a\u7684\u6a5f\u6703\u548c\u6311\u6230\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc\u5982\u4f55\u5728\u60a8\u7684\u696d\u52d9\u4e2d\u5be6\u65bd\u6709\u6548\u7684\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\u611f\u8208\u8da3\uff0c\u6216\u8005\u60f3\u4e86\u89e3\u66f4\u591a\u95dc\u65bc <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u548c <a href=\"https:\/\/server.hk\">\u96f2\u4f3a\u670d\u5668<\/a> \u7684\u8cc7\u8a0a\uff0c\u8acb\u96a8\u6642\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u4e0d\u53ef\u7f3a\u5c11\u7684\u6578\u64da\u5eab\u5171\u4eab\u6280\u8853\uff0c\u63d0\u5347\u6578\u64da\u7ba1\u7406\u6548\u7387\uff0c\u4fc3\u9032\u5718\u968a\u5354\u4f5c\uff0c\u5be6\u73fe\u4fe1\u606f\u7684\u7121\u7e2b\u6d41\u901a\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-152217","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152217","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=152217"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152217\/revisions"}],"predecessor-version":[{"id":152218,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/152217\/revisions\/152218"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=152217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=152217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=152217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}