{"id":63369,"date":"2025-04-29T08:46:49","date_gmt":"2025-04-29T00:46:49","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63369\/"},"modified":"2025-04-29T08:46:49","modified_gmt":"2025-04-29T00:46:49","slug":"phpstudy%e6%80%8e%e4%b9%88%e8%bf%9e%e6%8e%a5%e6%95%b0%e6%8d%ae%e5%ba%93-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63369\/","title":{"rendered":"phpstudy\u600e\u4e48\u8fde\u63a5\u6570\u636e\u5e93"},"content":{"rendered":"<blockquote><p>\n  \u7b54\u6848\uff1a \u662f\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7phpstudy\u8fde\u63a5\u6570\u636e\u5e93\u3002\u8be6\u7ec6\u6b65\u9aa4\uff1a\u5b89\u88c5mysql\u6570\u636e\u5e93\u5e76\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237\u3002\u5728phpstudy\u63a7\u5236\u9762\u677f\u4e2d\u914d\u7f6emysql\u4fe1\u606f\uff08\u4e3b\u673a\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u6570\u636e\u5e93\uff09\u3002\u5728php\u4ee3\u7801\u4e2d\u4f7f\u7528mysqli_connect\u51fd\u6570\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u6267\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\u6570\u636e\u5e93\u3002\u5b8c\u6210\u64cd\u4f5c\u540e\u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202404\/02\/2024040215271662916.jpg\" class=\"aligncenter\" title=\"phpstudy\u600e\u4e48\u8fde\u63a5\u6570\u636e\u5e93\u63d2\u56fe\" alt=\"phpstudy\u600e\u4e48\u8fde\u63a5\u6570\u636e\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>PHPStudy\u5982\u4f55\u8fde\u63a5\u6570\u636e\u5e93<\/strong><\/p>\n<p><strong>\u6b65\u9aa4 1\uff1a\u5b89\u88c5 MySQL \u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u4e0b\u8f7d MySQL \u5b89\u88c5\u7a0b\u5e8f\u5e76\u5b89\u88c5\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u548c\u7528\u6237\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 2\uff1a\u5728 PHPStudy \u4e2d\u914d\u7f6e MySQL<\/strong><\/p>\n<ul>\n<li>\u6253\u5f00 PHPStudy \u63a7\u5236\u9762\u677f\u3002<\/li>\n<li>\u5355\u51fb\u201c\u6570\u636e\u5e93\u201d\u9009\u9879\u5361\u3002<\/li>\n<li>\n<p>\u5728\u201cMySQL\u201d\u90e8\u5206\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li> <strong>\u4e3b\u673a\uff1a<\/strong> localhost \u6216 127.0.0.1<\/li>\n<li> <strong>\u7aef\u53e3\uff1a<\/strong> 3306\uff08\u9ed8\u8ba4\uff09<\/li>\n<li> <strong>\u7528\u6237\u540d\uff1a<\/strong> MySQL \u7528\u6237\u540d<\/li>\n<li> <strong>\u5bc6\u7801\uff1a<\/strong> MySQL \u5bc6\u7801<\/li>\n<li> <strong>\u6570\u636e\u5e93\uff1a<\/strong> \u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\u540d\u79f0<\/li>\n<\/ul>\n<\/li>\n<li>\u5355\u51fb\u201c\u542f\u52a8\u201d\u6309\u94ae\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 3\uff1a\u5728 PHP \u4ee3\u7801\u4e2d\u8fde\u63a5\u5230\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u5728 PHP \u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a<\/li>\n<\/ul>\n<pre>$link = mysqli_connect(\"localhost\", \"username\", \"password\", \"database\");<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5982\u679c\u8fde\u63a5\u6210\u529f\uff0c$link \u5c06\u5305\u542b\u4e00\u4e2a\u6709\u6548\u7684\u8fde\u63a5\u53e5\u67c4\u3002\u5426\u5219\uff0c$link \u5c06\u4e3a false\u3002<\/li>\n<\/ul>\n<p><strong>\u6b65\u9aa4 4\uff1a\u67e5\u8be2\u548c\u64cd\u4f5c\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u4e00\u65e6\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff0c\u5c31\u53ef\u4ee5\u6267\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\uff1a<\/li>\n<\/ul>\n<pre>\/\/ \u6267\u884c\u67e5\u8be2\n$result = mysqli_query($link, \"SELECT * FROM table\");\n\n\/\/ \u5904\u7406\u67e5\u8be2\u7ed3\u679c\nwhile ($row = mysqli_fetch_array($result)) {\n    echo $row['column_name'] . '&lt;br&gt;';\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6b65\u9aa4 5\uff1a\u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5<\/strong><\/p>\n<ul>\n<li>\u5b8c\u6210\u6570\u636e\u5e93\u64cd\u4f5c\u540e\uff0c\u5e94\u5173\u95ed\u8fde\u63a5\uff1a<\/li>\n<\/ul>\n<pre>mysqli_close($link);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8fde\u63a5\u6570\u636e\u5e93\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b54\u6848\uff1a \u662f\u7684\uff0c\u53ef\u4ee5\u901a\u8fc7phpstudy\u8fde\u63a5\u6570\u636e\u5e93\u3002\u8be6\u7ec6\u6b65\u9aa4\uff1a\u5b89\u88c5mysql\u6570\u636e\u5e93\u5e76\u521b\u5efa\u6570\u636e\u5e93\u548c\u7528\u6237\u3002\u5728phpstudy\u63a7\u5236\u9762\u677f\u4e2d\u914d\u7f6emysql\u4fe1\u606f\uff08\u4e3b\u673a\u3001\u7aef\u53e3\u3001\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u6570\u636e\u5e93\uff09\u3002\u5728php\u4ee3\u7801\u4e2d\u4f7f\u7528mysqli_connect\u51fd\u6570\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002\u6267\u884c\u67e5\u8be2\u548c\u64cd\u4f5c\u6570\u636e\u5e93\u3002\u5b8c\u6210\u64cd\u4f5c\u540e\u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\u3002 PHPStudy\u5982\u4f55\u8fde\u63a5\u6570\u636e\u5e93 \u6b65\u9aa4 1\uff1a\u5b89\u88c5 MySQL \u6570\u636e\u5e93 \u4e0b\u8f7d MySQL \u5b89\u88c5\u7a0b\u5e8f\u5e76\u5b89\u88c5\u3002 \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6570\u636e\u5e93\u548c\u7528\u6237\u3002 \u6b65\u9aa4 2\uff1a\u5728 PHPStudy \u4e2d\u914d\u7f6e MySQL \u6253\u5f00 PHPStudy \u63a7\u5236\u9762\u677f\u3002 \u5355\u51fb\u201c\u6570\u636e\u5e93\u201d\u9009\u9879\u5361\u3002 \u5728\u201cMySQL\u201d\u90e8\u5206\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u4fe1\u606f\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4e3b\u673a\uff1a localhost \u6216 127.0.0.1 \u7aef\u53e3\uff1a 3306\uff08\u9ed8\u8ba4\uff09 \u7528\u6237\u540d\uff1a MySQL \u7528\u6237\u540d \u5bc6\u7801\uff1a MySQL \u5bc6\u7801 \u6570\u636e\u5e93\uff1a \u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\u540d\u79f0 \u5355\u51fb\u201c\u542f\u52a8\u201d\u6309\u94ae\u3002 \u6b65\u9aa4 3\uff1a\u5728 PHP \u4ee3\u7801\u4e2d\u8fde\u63a5\u5230\u6570\u636e\u5e93 \u5728 PHP \u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u8fde\u63a5\u5230\u6570\u636e\u5e93\uff1a $link = mysqli_connect(&#8220;localhost&#8221;, &#8220;username&#8221;, &#8220;password&#8221;, &#8220;database&#8221;); \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u8fde\u63a5\u6210\u529f\uff0c$link \u5c06\u5305\u542b\u4e00\u4e2a\u6709\u6548\u7684\u8fde\u63a5\u53e5\u67c4\u3002\u5426\u5219\uff0c$link \u5c06\u4e3a false\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63369","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63369"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63369\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}