{"id":6000,"date":"2024-11-14T12:22:25","date_gmt":"2024-11-14T04:22:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6000\/"},"modified":"2024-11-14T12:22:25","modified_gmt":"2024-11-14T04:22:25","slug":"%e5%a6%82%e4%bd%95%e7%94%a8mysql%e5%bb%ba%e7%ab%8b%e6%95%b0%e6%8d%ae%e5%ba%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6000\/","title":{"rendered":"\u5982\u4f55\u7528mysql\u5efa\u7acb\u6570\u636e\u5e93"},"content":{"rendered":"<blockquote><p>\n  \u521b\u5efa mysql \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a\u6253\u5f00 mysql \u547d\u4ee4\u884c\u5e76\u8f93\u5165\u6839\u7528\u6237\u5bc6\u7801\u3002\u4f7f\u7528 create database \u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u3002\u4f7f\u7528 use \u547d\u4ee4\u9009\u62e9\u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528 create table \u547d\u4ee4\u521b\u5efa\u8868\uff0c\u6307\u5b9a\u5217\u540d\u79f0\u548c\u6570\u636e\u7c7b\u578b\u3002\u4f7f\u7528 insert into \u547d\u4ee4\u5c06\u6570\u636e\u63d2\u5165\u8868\u4e2d\u3002\u4f7f\u7528 select \u547d\u4ee4\u4ece\u8868\u4e2d\u67e5\u8be2\u6570\u636e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/12\/2024061214213239743.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528mysql\u5efa\u7acb\u6570\u636e\u5e93\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528mysql\u5efa\u7acb\u6570\u636e\u5e93\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7528 MySQL \u5efa\u7acb\u6570\u636e\u5e93<\/strong><\/p>\n<p><strong>1. \u6253\u5f00 MySQL \u547d\u4ee4\u884c\u5de5\u5177<\/strong><\/p>\n<ul>\n<li>\u5728 Windows \u4e0a\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u5e76\u8f93\u5165 &#8221; -u root -p&#8221;\u3002<\/li>\n<li>\u5728 macOS \u6216 Linux \u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165 &#8220;mysql -u root -p&#8221;\u3002<\/li>\n<li>\u8f93\u5165 MySQL \u7684\u6839\u7528\u6237\u5bc6\u7801\u3002<\/li>\n<\/ul>\n<p><strong>2. \u521b\u5efa\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\uff1a<\/li>\n<\/ul>\n<pre>CREATE DATABASE database_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 &#8220;database_name&#8221; \u66ff\u6362\u4e3a\u8981\u521b\u5efa\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002<\/li>\n<\/ul>\n<p><strong>3. \u9009\u62e9\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9009\u62e9\u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\uff1a<\/li>\n<\/ul>\n<pre>USE database_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u521b\u5efa\u8868<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a &#8220;table_name&#8221; \u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u5217 &#8220;column_name&#8221; \u548c &#8220;data_type&#8221;\uff1a<\/li>\n<\/ul>\n<pre>CREATE TABLE table_name (\n  column_name data_type,\n  ...\n);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u4ee5\u521b\u5efa\u5176\u4ed6\u8868\u3002<\/li>\n<\/ul>\n<p><strong>5. \u63d2\u5165\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5c06\u6570\u636e\u63d2\u5165\u5230\u8868\u4e2d\uff1a<\/li>\n<\/ul>\n<pre>INSERT INTO table_name (column_name, ...) VALUES (value1, ...);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4\u4ee5\u63d2\u5165\u5176\u4ed6\u6570\u636e\u3002<\/li>\n<\/ul>\n<p><strong>6. \u67e5\u8be2\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4ece\u8868\u4e2d\u67e5\u8be2\u6570\u636e\uff1a<\/li>\n<\/ul>\n<pre>SELECT column_name, ... FROM table_name WHERE condition;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u5c06 &#8220;column_name&#8221; \u66ff\u6362\u4e3a\u8981\u67e5\u8be2\u7684\u5217\u540d\u79f0\u3002<\/li>\n<li>\u5c06 &#8220;condition&#8221; \u66ff\u6362\u4e3a\u67e5\u8be2\u6761\u4ef6\uff08\u4f8b\u5982\uff0c&#8221;WHERE id = 1&#8243;\uff09\u3002<\/li>\n<\/ul>\n<p><strong>\u63d0\u793a\uff1a<\/strong><\/p>\n<ul>\n<li>\u6570\u636e\u5e93\u540d\u79f0\u5e94\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\u3002<\/li>\n<li>\u8868\u540d\u79f0\u5e94\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\u548c\u4e0b\u5212\u7ebf\u3002<\/li>\n<li>\u5217\u540d\u79f0\u5e94\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\u548c\u4e0b\u5212\u7ebf\u3002<\/li>\n<li>\u6570\u636e\u7c7b\u578b\u53ef\u4ee5\u662f\u6574\u6570\uff08INT\uff09\u3001\u5b57\u7b26\u4e32\uff08VARCHAR\uff09\u3001\u65e5\u671f\uff08DATE\uff09\u7b49\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u7528\u5efa\u7acb\u6570\u636e\u5e93\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>\u521b\u5efa mysql \u6570\u636e\u5e93\u7684\u6b65\u9aa4\uff1a\u6253\u5f00 mysql \u547d\u4ee4\u884c\u5e76\u8f93\u5165\u6839\u7528\u6237\u5bc6\u7801\u3002\u4f7f\u7528 create database \u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\u3002\u4f7f\u7528 use \u547d\u4ee4\u9009\u62e9\u65b0\u521b\u5efa\u7684\u6570\u636e\u5e93\u3002\u4f7f\u7528 create table \u547d\u4ee4\u521b\u5efa\u8868\uff0c\u6307\u5b9a\u5217\u540d\u79f0\u548c\u6570\u636e\u7c7b\u578b\u3002\u4f7f\u7528 insert into \u547d\u4ee4\u5c06\u6570\u636e\u63d2\u5165\u8868\u4e2d\u3002\u4f7f\u7528 select \u547d\u4ee4\u4ece\u8868\u4e2d\u67e5\u8be2\u6570\u636e\u3002 \u5982\u4f55\u7528 MySQL \u5efa\u7acb\u6570\u636e\u5e93 1. \u6253\u5f00 MySQL \u547d\u4ee4\u884c\u5de5\u5177 \u5728 Windows \u4e0a\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u5e76\u8f93\u5165 &#8221; -u root -p&#8221;\u3002 \u5728 macOS \u6216 Linux \u4e0a\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165 &#8220;mysql -u root -p&#8221;\u3002 \u8f93\u5165 MySQL \u7684\u6839\u7528\u6237\u5bc6\u7801\u3002 2. \u521b\u5efa\u6570\u636e\u5e93 \u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u6570\u636e\u5e93\uff1a CREATE DATABASE database_name; \u767b\u5f55\u540e\u590d\u5236 \u5c06 &#8220;database_name&#8221; \u66ff\u6362\u4e3a\u8981\u521b\u5efa\u6570\u636e\u5e93\u7684\u540d\u79f0\u3002 3. [&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-6000","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6000","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=6000"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6000\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6000"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6000"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6000"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}