{"id":58359,"date":"2024-10-12T20:06:36","date_gmt":"2024-10-12T12:06:36","guid":{"rendered":"https:\/\/server.hk\/cnblog\/58359\/"},"modified":"2024-10-12T20:06:36","modified_gmt":"2024-10-12T12:06:36","slug":"amh4-2%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e6%96%b9%e6%b3%95%e7%b0%a1%e4%bb%8b-amh4-2-%e6%95%b8%e6%93%9a%e5%ba%ab%e6%80%8e%e9%ba%bc%e9%80%a3%e6%8e%a5","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/58359\/","title":{"rendered":"AMH4.2\u6578\u64da\u5eab\u9023\u63a5\u65b9\u6cd5\u7c21\u4ecb (amh4.2 \u6578\u64da\u5eab\u600e\u9ebc\u9023\u63a5)"},"content":{"rendered":"<h1 id=\"amh4-2%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e6%96%b9%e6%b3%95%e7%b0%a1%e4%bb%8b-RmSgHSNevr\">AMH4.2\u6578\u64da\u5eab\u9023\u63a5\u65b9\u6cd5\u7c21\u4ecb<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u6578\u64da\u5eab\u7684\u7ba1\u7406\u548c\u9023\u63a5\u662f\u7db2\u7ad9\u904b\u884c\u7684\u6838\u5fc3\u90e8\u5206\u3002AMH\uff08\u963f\u7f8e\u597d\uff09\u4f5c\u70ba\u4e00\u6b3e\u6d41\u884c\u7684\u7db2\u7ad9\u7ba1\u7406\u9762\u677f\uff0c\u51764.2\u7248\u672c\u63d0\u4f9b\u4e86\u591a\u7a2e\u6578\u64da\u5eab\u9023\u63a5\u7684\u65b9\u6cd5\u3002\u672c\u6587\u5c07\u4ecb\u7d39AMH4.2\u7684\u6578\u64da\u5eab\u9023\u63a5\u65b9\u6cd5\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u597d\u5730\u7406\u89e3\u5982\u4f55\u6709\u6548\u5730\u7ba1\u7406\u548c\u4f7f\u7528\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"amh4-2%e7%9a%84%e6%95%b8%e6%93%9a%e5%ba%ab%e6%a6%82%e8%bf%b0-RmSgHSNevr\">AMH4.2\u7684\u6578\u64da\u5eab\u6982\u8ff0<\/h2>\n<p>AMH4.2\u652f\u6301\u591a\u7a2e\u6578\u64da\u5eab\uff0c\u5305\u62ecMySQL\u548cMariaDB\u3002\u9019\u4e9b\u6578\u64da\u5eab\u7cfb\u7d71\u4ee5\u5176\u9ad8\u6548\u6027\u548c\u7a69\u5b9a\u6027\u800c\u53d7\u5230\u5ee3\u6cdb\u4f7f\u7528\u3002\u7528\u6236\u53ef\u4ee5\u901a\u904eAMH\u9762\u677f\u8f15\u9b06\u5730\u5275\u5efa\u3001\u7ba1\u7406\u548c\u9023\u63a5\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e5%ba%ab%e9%80%a3%e6%8e%a5%e7%9a%84%e5%9f%ba%e6%9c%ac%e6%ad%a5%e9%a9%9f-RmSgHSNevr\">\u6578\u64da\u5eab\u9023\u63a5\u7684\u57fa\u672c\u6b65\u9a5f<\/h2>\n<p>\u5728AMH4.2\u4e2d\uff0c\u9023\u63a5\u6578\u64da\u5eab\u7684\u57fa\u672c\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li><strong>\u767b\u9304AMH\u9762\u677f\uff1a<\/strong>\u9996\u5148\uff0c\u7528\u6236\u9700\u8981\u4f7f\u7528\u7ba1\u7406\u54e1\u8cec\u6236\u767b\u9304AMH\u9762\u677f\u3002<\/li>\n<li><strong>\u5275\u5efa\u6578\u64da\u5eab\uff1a<\/strong>\u5728\u9762\u677f\u4e2d\uff0c\u9078\u64c7\u201c\u6578\u64da\u5eab\u7ba1\u7406\u201d\u9078\u9805\uff0c\u7136\u5f8c\u9ede\u64ca\u201c\u5275\u5efa\u6578\u64da\u5eab\u201d\u3002\u7528\u6236\u9700\u8981\u586b\u5beb\u6578\u64da\u5eab\u540d\u7a31\u3001\u7528\u6236\u540d\u548c\u5bc6\u78bc\u7b49\u4fe1\u606f\u3002<\/li>\n<li><strong>\u914d\u7f6e\u6578\u64da\u5eab\u9023\u63a5\uff1a<\/strong>\u5728\u5275\u5efa\u6578\u64da\u5eab\u5f8c\uff0c\u7528\u6236\u9700\u8981\u914d\u7f6e\u61c9\u7528\u7a0b\u5e8f\u7684\u6578\u64da\u5eab\u9023\u63a5\u4fe1\u606f\uff0c\u5305\u62ec\u4e3b\u6a5f\u5730\u5740\u3001\u7528\u6236\u540d\u3001\u5bc6\u78bc\u548c\u6578\u64da\u5eab\u540d\u7a31\u3002<\/li>\n<\/ol>\n<h2 id=\"%e4%bd%bf%e7%94%a8php%e9%80%a3%e6%8e%a5mysql%e6%95%b8%e6%93%9a%e5%ba%ab-RmSgHSNevr\">\u4f7f\u7528PHP\u9023\u63a5MySQL\u6578\u64da\u5eab<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u500b\u4f7f\u7528PHP\u9023\u63a5MySQL\u6578\u64da\u5eab\u7684\u793a\u4f8b\u4ee3\u78bc\uff1a<\/p>\n<pre><code>&lt;?php\n$servername = \"localhost\"; \/\/ \u6578\u64da\u5eab\u4e3b\u6a5f\n$username = \"your_username\"; \/\/ \u6578\u64da\u5eab\u7528\u6236\u540d\n$password = \"your_password\"; \/\/ \u6578\u64da\u5eab\u5bc6\u78bc\n$dbname = \"your_database\"; \/\/ \u6578\u64da\u5eab\u540d\u7a31\n\n\/\/ \u5275\u5efa\u9023\u63a5\n$conn = new mysqli($servername, $username, $password, $dbname);\n\n\/\/ \u6aa2\u67e5\u9023\u63a5\nif ($conn-&gt;connect_error) {\n    die(\"\u9023\u63a5\u5931\u6557: \" . $conn-&gt;connect_error);\n}\necho \"\u9023\u63a5\u6210\u529f\";\n?&gt;<\/code><\/pre>\n<p>\u5728\u9019\u6bb5\u4ee3\u78bc\u4e2d\uff0c\u7528\u6236\u9700\u8981\u6839\u64da\u81ea\u5df1\u7684\u6578\u64da\u5eab\u8a2d\u7f6e\u66ff\u63db\u76f8\u61c9\u7684\u8b8a\u91cf\u3002\u6210\u529f\u9023\u63a5\u5f8c\uff0c\u5c07\u986f\u793a\u201c\u9023\u63a5\u6210\u529f\u201d\u7684\u6d88\u606f\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8%e5%85%b6%e4%bb%96%e8%aa%9e%e8%a8%80%e9%80%a3%e6%8e%a5%e6%95%b8%e6%93%9a%e5%ba%ab-RmSgHSNevr\">\u4f7f\u7528\u5176\u4ed6\u8a9e\u8a00\u9023\u63a5\u6578\u64da\u5eab<\/h2>\n<p>\u9664\u4e86PHP\uff0cAMH4.2\u9084\u652f\u6301\u5176\u4ed6\u7de8\u7a0b\u8a9e\u8a00\u9023\u63a5\u6578\u64da\u5eab\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Python\u9023\u63a5MySQL\u7684\u4ee3\u78bc\u5982\u4e0b\uff1a<\/p>\n<pre><code>import mysql.connector\n\n# \u5275\u5efa\u9023\u63a5\nconn = mysql.connector.connect(\n    host=\"localhost\",\n    user=\"your_username\",\n    password=\"your_password\",\n    database=\"your_database\"\n)\n\n# \u6aa2\u67e5\u9023\u63a5\nif conn.is_connected():\n    print(\"\u9023\u63a5\u6210\u529f\")\nelse:\n    print(\"\u9023\u63a5\u5931\u6557\")\n<\/code><\/pre>\n<p>\u9019\u6bb5\u4ee3\u78bc\u540c\u6a23\u9700\u8981\u7528\u6236\u6839\u64da\u81ea\u5df1\u7684\u6578\u64da\u5eab\u8a2d\u7f6e\u9032\u884c\u76f8\u61c9\u7684\u4fee\u6539\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c%e5%8f%8a%e8%a7%a3%e6%b1%ba%e6%96%b9%e6%a1%88-RmSgHSNevr\">\u5e38\u898b\u554f\u984c\u53ca\u89e3\u6c7a\u65b9\u6848<\/h2>\n<ul>\n<li><strong>\u9023\u63a5\u8d85\u6642\uff1a<\/strong>\u6aa2\u67e5\u9632\u706b\u7246\u8a2d\u7f6e\uff0c\u78ba\u4fdd\u6578\u64da\u5eab\u7aef\u53e3\uff08\u9ed8\u8a8d\u70ba3306\uff09\u5df2\u958b\u653e\u3002<\/li>\n<li><strong>\u8a8d\u8b49\u5931\u6557\uff1a<\/strong>\u78ba\u8a8d\u7528\u6236\u540d\u548c\u5bc6\u78bc\u662f\u5426\u6b63\u78ba\uff0c\u4e26\u6aa2\u67e5\u7528\u6236\u662f\u5426\u6709\u8a2a\u554f\u8a72\u6578\u64da\u5eab\u7684\u6b0a\u9650\u3002<\/li>\n<li><strong>\u6578\u64da\u5eab\u4e0d\u5b58\u5728\uff1a<\/strong>\u78ba\u4fdd\u5728\u9023\u63a5\u6642\u4f7f\u7528\u7684\u6578\u64da\u5eab\u540d\u7a31\u6b63\u78ba\u7121\u8aa4\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-RmSgHSNevr\">\u7e3d\u7d50<\/h2>\n<p>AMH4.2\u63d0\u4f9b\u4e86\u9748\u6d3b\u4e14\u9ad8\u6548\u7684\u6578\u64da\u5eab\u9023\u63a5\u65b9\u6cd5\uff0c\u7121\u8ad6\u662f\u4f7f\u7528PHP\u9084\u662f\u5176\u4ed6\u7de8\u7a0b\u8a9e\u8a00\uff0c\u7528\u6236\u90fd\u80fd\u8f15\u9b06\u5730\u7ba1\u7406\u548c\u64cd\u4f5c\u6578\u64da\u5eab\u3002\u4e86\u89e3\u9019\u4e9b\u57fa\u672c\u7684\u9023\u63a5\u65b9\u6cd5\u5c0d\u65bc\u7db2\u7ad9\u7684\u904b\u884c\u81f3\u95dc\u91cd\u8981\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u53ef\u4ee5\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u7db2\u7ad9\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3AMH4.2\u6578\u64da\u5eab\u7684\u9023\u63a5\u65b9\u6cd5\uff0c\u7c21\u55ae\u6b65\u9a5f\u6559\u4f60\u5982\u4f55\u8f15\u9b06\u9023\u63a5\u548c\u7ba1\u7406\u6578\u64da\u5eab\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-58359","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/58359","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=58359"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/58359\/revisions"}],"predecessor-version":[{"id":58360,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/58359\/revisions\/58360"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=58359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=58359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=58359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}