{"id":6679,"date":"2024-11-14T12:48:03","date_gmt":"2024-11-14T04:48:03","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6679\/"},"modified":"2024-11-14T12:48:03","modified_gmt":"2024-11-14T04:48:03","slug":"mysql%e5%ae%89%e8%a3%85%e4%ba%86%e6%80%8e%e4%b9%88%e4%bd%bf%e7%94%a8-%e5%ae%89%e8%a3%85%e5%a5%bdmysql%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6679\/","title":{"rendered":"mysql\u5b89\u88c5\u4e86\u600e\u4e48\u4f7f\u7528 \u5b89\u88c5\u597dmysql\u5982\u4f55\u4f7f\u7528\u6559\u7a0b"},"content":{"rendered":"<blockquote><p>\n  \u5982\u679c\u4f60\u5df2\u6210\u529f\u5b89\u88c5 mysql\uff0c\u73b0\u5728\u60f3\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u5b83\uff0c\u672c\u6307\u5357\u5c06\u9010\u6b65\u6307\u5bfc\u4f60\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u521d\u59cb\u914d\u7f6e\uff0c\u5305\u62ec\u8bbe\u7f6eroot\u5bc6\u7801\u3001\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\uff0c\u4ee5\u53ca\u6388\u4e88\u7528\u6237\u8bbf\u95ee\u6743\u9650\u3002\u4e86\u89e3\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\u540e\uff0c\u4f60\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3 mysql \u7684\u9ad8\u7ea7\u529f\u80fd\uff0c\u4f8b\u5982\u8054\u5408\u3001\u5b50\u67e5\u8be2\u548c\u5b58\u50a8\u8fc7\u7a0b\u3002\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u6280\u672f\uff0c\u4f60\u5c06\u80fd\u591f\u6709\u6548\u5730\u4f7f\u7528 mysql \u7ba1\u7406\u548c\u67e5\u8be2\u6570\u636e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202410\/17\/2024101714373861500.jpg\" class=\"aligncenter\" title=\"mysql\u5b89\u88c5\u4e86\u600e\u4e48\u4f7f\u7528 \u5b89\u88c5\u597dmysql\u5982\u4f55\u4f7f\u7528\u6559\u7a0b\u63d2\u56fe\" alt=\"mysql\u5b89\u88c5\u4e86\u600e\u4e48\u4f7f\u7528 \u5b89\u88c5\u597dmysql\u5982\u4f55\u4f7f\u7528\u6559\u7a0b\u63d2\u56fe\" \/><\/p>\n<h2>MySQL \u5b89\u88c5\u540e\u4f7f\u7528\u6559\u7a0b<\/h2>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>1. \u8fde\u63a5 MySQL<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u4f7f\u7528\u7ec8\u7aef\u5de5\u5177\uff08\u5982 Windows \u547d\u4ee4\u63d0\u793a\u7b26\u6216 macOS \u7ec8\u7aef\uff09\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a<\/p>\n<pre>mysql&nbsp;-u&nbsp;root&nbsp;-p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\u8f93\u5165 MySQL root \u7528\u6237\u7684\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>2. \u521b\u5efa\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u636e\u5e93\uff1a<\/p>\n<pre>CREATE&nbsp;DATABASE&nbsp;mydatabase;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u9009\u4e2d\u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\uff1a<\/p>\n<pre>USE&nbsp;mydatabase;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>3. \u521b\u5efa\u8868<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&nbsp;customers&nbsp;\u7684\u8868\uff1a<\/p>\n<pre>CREATE&nbsp;TABLE&nbsp;customers&nbsp;(\nid&nbsp;INT&nbsp;NOT&nbsp;NULL&nbsp;AUTO_INCREMENT,\nname&nbsp;VARCHAR(255)&nbsp;NOT&nbsp;NULL,\nemail&nbsp;VARCHAR(255)&nbsp;NOT&nbsp;NULL,\nPRIMARY&nbsp;KEY&nbsp;(id)\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>4. \u63d2\u5165\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u63d2\u5165\u6570\u636e\u5230&nbsp;customers&nbsp;\u8868\uff1a<\/p>\n<pre>INSERT&nbsp;INTO&nbsp;customers&nbsp;(name,&nbsp;email)&nbsp;VALUES&nbsp;('John&nbsp;Doe',&nbsp;'john.doe@example.com');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>5. \u67e5\u8be2\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u67e5\u8be2&nbsp;customers&nbsp;\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\uff1a<\/p>\n<pre>SELECT&nbsp;*&nbsp;FROM&nbsp;customers;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>6. \u66f4\u65b0\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u66f4\u65b0 John Doe \u7684 email \u5730\u5740\uff1a<\/p>\n<pre>UPDATE&nbsp;customers&nbsp;SET&nbsp;email&nbsp;=&nbsp;'john.doe@newdomain.com'&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>7. \u5220\u9664\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\n<p style=\"margin-top: 0px;margin-bottom: 9px\">\u5220\u9664 id \u4e3a 1 \u7684\u8bb0\u5f55\uff1a<\/p>\n<pre>DELETE&nbsp;FROM&nbsp;customers&nbsp;WHERE&nbsp;id&nbsp;=&nbsp;1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>8. \u9ad8\u7ea7\u64cd\u4f5c<\/strong><\/p>\n<ul>\n<li> <strong>\u5916\u952e\u7ea6\u675f\uff1a<\/strong>\u521b\u5efa\u5916\u952e\u7ea6\u675f\u4ee5\u5f3a\u5236\u6267\u884c\u8868\u4e4b\u95f4\u7684\u5173\u7cfb\u3002<\/li>\n<li> <strong>\u89e6\u53d1\u5668\uff1a<\/strong>\u5728\u5bf9\u8868\u8fdb\u884c\u7279\u5b9a\u64cd\u4f5c\u65f6\u89e6\u53d1\u9884\u5b9a\u7684\u64cd\u4f5c\u3002<\/li>\n<li> <strong>\u5b58\u50a8\u8fc7\u7a0b\uff1a<\/strong>\u5c01\u88c5\u5e38\u89c1 SQL \u64cd\u4f5c\u7684\u9884\u7f16\u8bd1\u4ee3\u7801\u5757\u3002<\/li>\n<li> <strong>\u7d22\u5f15\uff1a<\/strong>\u63d0\u9ad8\u67e5\u8be2\u901f\u5ea6\u3002<\/li>\n<\/ul>\n<p style=\"margin-top: 0px;margin-bottom: 9px;font-family:\"><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u60a8\u53ef\u4ee5\u4f7f\u7528 MySQL \u5ba2\u6237\u7aef\uff08\u5982 MySQL Workbench\uff09\u56fe\u5f62\u5316\u5730\u7ba1\u7406 MySQL \u6570\u636e\u5e93\u3002<\/li>\n<li>\u4f7f\u7528&nbsp;DESCRIBE <\/li>\n<li>\u7528&nbsp;ALTER TABLE&nbsp;\u4fee\u6539\u8868\u7684\u7ed3\u6784\u3002<\/li>\n<li>\u7528&nbsp;DROP DATABASE&nbsp;\u548c&nbsp;DROP TABLE&nbsp;\u5220\u9664\u6570\u636e\u5e93\u6216\u8868\u3002<\/li>\n<li>\u7528\u6237&nbsp;root&nbsp;\u662f MySQL \u7684\u8d85\u7ea7\u7528\u6237\uff0c\u5177\u6709\u5b8c\u5168\u6743\u9650\u3002<\/li>\n<li>\u786e\u4fdd\u4f7f\u7528\u5b89\u5168\u5bc6\u7801\u4fdd\u62a4\u60a8\u7684 MySQL \u6570\u636e\u5e93\u3002<\/li>\n<table>\n   &nbsp;\u67e5\u770b\u8868\u7684\u7ed3\u6784\u3002<br \/>\n <\/table>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5b89\u88c5\u4e86\u600e\u4e48\u4f7f\u7528 \u5b89\u88c5\u597dmysql\u5982\u4f55\u4f7f\u7528\u6559\u7a0b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u4f60\u5df2\u6210\u529f\u5b89\u88c5 mysql\uff0c\u73b0\u5728\u60f3\u77e5\u9053\u5982\u4f55\u4f7f\u7528\u5b83\uff0c\u672c\u6307\u5357\u5c06\u9010\u6b65\u6307\u5bfc\u4f60\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u521d\u59cb\u914d\u7f6e\uff0c\u5305\u62ec\u8bbe\u7f6eroot\u5bc6\u7801\u3001\u521b\u5efa\u6570\u636e\u5e93\u548c\u8868\uff0c\u4ee5\u53ca\u6388\u4e88\u7528\u6237\u8bbf\u95ee\u6743\u9650\u3002\u4e86\u89e3\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\u540e\uff0c\u4f60\u53ef\u4ee5\u6df1\u5165\u4e86\u89e3 mysql \u7684\u9ad8\u7ea7\u529f\u80fd\uff0c\u4f8b\u5982\u8054\u5408\u3001\u5b50\u67e5\u8be2\u548c\u5b58\u50a8\u8fc7\u7a0b\u3002\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b\u6280\u672f\uff0c\u4f60\u5c06\u80fd\u591f\u6709\u6548\u5730\u4f7f\u7528 mysql \u7ba1\u7406\u548c\u67e5\u8be2\u6570\u636e\u3002 MySQL \u5b89\u88c5\u540e\u4f7f\u7528\u6559\u7a0b 1. \u8fde\u63a5 MySQL \u4f7f\u7528\u7ec8\u7aef\u5de5\u5177\uff08\u5982 Windows \u547d\u4ee4\u63d0\u793a\u7b26\u6216 macOS \u7ec8\u7aef\uff09\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\uff1a mysql&nbsp;-u&nbsp;root&nbsp;-p \u767b\u5f55\u540e\u590d\u5236 \u8f93\u5165 MySQL root \u7528\u6237\u7684\u5bc6\u7801\u3002 2. \u521b\u5efa\u6570\u636e\u5e93 \u521b\u5efa\u4e00\u4e2a\u65b0\u6570\u636e\u5e93\uff1a CREATE&nbsp;DATABASE&nbsp;mydatabase; \u767b\u5f55\u540e\u590d\u5236 \u9009\u4e2d\u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\uff1a USE&nbsp;mydatabase; \u767b\u5f55\u540e\u590d\u5236 3. \u521b\u5efa\u8868 \u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&nbsp;customers&nbsp;\u7684\u8868\uff1a CREATE&nbsp;TABLE&nbsp;customers&nbsp;( id&nbsp;INT&nbsp;NOT&nbsp;NULL&nbsp;AUTO_INCREMENT, name&nbsp;VARCHAR(255)&nbsp;NOT&nbsp;NULL, email&nbsp;VARCHAR(255)&nbsp;NOT&nbsp;NULL, PRIMARY&nbsp;KEY&nbsp;(id) ); \u767b\u5f55\u540e\u590d\u5236 4. \u63d2\u5165\u6570\u636e \u63d2\u5165\u6570\u636e\u5230&nbsp;customers&nbsp;\u8868\uff1a INSERT&nbsp;INTO&nbsp;customers&nbsp;(name,&nbsp;email)&nbsp;VALUES&nbsp;(&#8216;John&nbsp;Doe&#8217;,&nbsp;&#8216;john.doe@example.com&#8217;); \u767b\u5f55\u540e\u590d\u5236 5. \u67e5\u8be2\u6570\u636e \u67e5\u8be2&nbsp;customers&nbsp;\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\uff1a SELECT&nbsp;*&nbsp;FROM&nbsp;customers; \u767b\u5f55\u540e\u590d\u5236 6. \u66f4\u65b0\u6570\u636e \u66f4\u65b0 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6679","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6679","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=6679"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6679\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}