{"id":6170,"date":"2024-11-14T12:41:44","date_gmt":"2024-11-14T04:41:44","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6170\/"},"modified":"2024-11-14T12:41:44","modified_gmt":"2024-11-14T04:41:44","slug":"%e5%a6%82%e4%bd%95%e6%b5%8b%e8%af%95mysql%e5%ae%89%e8%a3%85%e6%88%90%e5%8a%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6170\/","title":{"rendered":"\u5982\u4f55\u6d4b\u8bd5mysql\u5b89\u88c5\u6210\u529f"},"content":{"rendered":"<blockquote><p>\n  \u8981\u6d4b\u8bd5 mysql \u5b89\u88c5\u662f\u5426\u6210\u529f\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u68c0\u67e5\u670d\u52a1\u72b6\u6001\uff08mysql -u root -p\uff09\u521b\u5efa\u6d4b\u8bd5\u6570\u636e\u5e93\uff08create database testdb;\uff09\u9009\u62e9\u6d4b\u8bd5\u6570\u636e\u5e93\uff08use testdb;\uff09\u521b\u5efa\u6d4b\u8bd5\u8868\uff08create table test_table (id int not null auto_increment, name varchar(255), primary key (id));\uff09\u63d2\u5165\u6d4b\u8bd5\u6570\u636e\uff08insert into test_table (name) values (&#8216;\u6d4b\u8bd5\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/14\/2024061404062672487.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u6d4b\u8bd5mysql\u5b89\u88c5\u6210\u529f\u63d2\u56fe\" alt=\"\u5982\u4f55\u6d4b\u8bd5mysql\u5b89\u88c5\u6210\u529f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u6d4b\u8bd5 MySQL \u5b89\u88c5\u6210\u529f<\/strong><\/p>\n<p>\u5b89\u88c5 MySQL \u540e\uff0c\u6d4b\u8bd5\u5176\u662f\u5426\u6210\u529f\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5c06\u6307\u5bfc\u60a8\u9a8c\u8bc1\u5b89\u88c5\uff1a<\/p>\n<p><strong>1. \u68c0\u67e5 MySQL \u670d\u52a1\u72b6\u6001<\/strong><\/p>\n<ul>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff08\u5982 CMD \u6216 Terminal\uff09<\/li>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>mysql -u root -p<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165\u5bc6\u7801\u3002\u8f93\u5165\u60a8\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u7684 root \u5bc6\u7801\u3002<\/li>\n<li>\u6210\u529f\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u540e\uff0c\u60a8\u5c06\u770b\u5230 MySQL \u63d0\u793a\u7b26\u3002<\/li>\n<\/ul>\n<p><strong>2. \u521b\u5efa\u6d4b\u8bd5\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u5728 MySQL \u63d0\u793a\u7b26\u4e0b\uff0c\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>CREATE DATABASE testdb;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a &#8220;testdb&#8221; \u7684\u65b0\u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<p><strong>3. \u9009\u62e9\u6d4b\u8bd5\u6570\u636e\u5e93<\/strong><\/p>\n<ul>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>USE testdb;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8fd9\u5c06\u9009\u62e9\u60a8\u521a\u521a\u521b\u5efa\u7684 &#8220;testdb&#8221; \u6570\u636e\u5e93\u3002<\/li>\n<\/ul>\n<p><strong>4. \u521b\u5efa\u6d4b\u8bd5\u8868<\/strong><\/p>\n<ul>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>CREATE TABLE test_table (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(255), PRIMARY KEY (id));<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8fd9\u5c06\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a &#8220;test_table&#8221; \u7684\u65b0\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e24\u4e2a\u5217\uff1aid \u548c name\u3002<\/li>\n<\/ul>\n<p><strong>5. \u63d2\u5165\u6d4b\u8bd5\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>INSERT INTO test_table (name) VALUES ('\u6d4b\u8bd5\u6570\u636e');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8fd9\u5728 &#8220;test_table&#8221; \u4e2d\u63d2\u5165\u4e00\u6761\u65b0\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n<p><strong>6. \u67e5\u8be2\u6d4b\u8bd5\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>SELECT * FROM test_table;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8fd9\u5c06\u68c0\u7d22 &#8220;test_table&#8221; \u4e2d\u7684\u6240\u6709\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n<p><strong>7. \u5220\u9664\u6d4b\u8bd5\u6570\u636e\u548c\u8868<\/strong><\/p>\n<ul>\n<li>\u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/li>\n<\/ul>\n<pre>DELETE FROM test_table WHERE id = 1;\nDROP TABLE test_table;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u8fd9\u5c06\u5220\u9664\u521a\u63d2\u5165\u7684\u6d4b\u8bd5\u6570\u636e\u548c &#8220;test_table&#8221; \u8868\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u6240\u6709\u6b65\u9aa4\u6210\u529f\u6267\u884c\uff0c\u5219\u8868\u793a MySQL \u5df2\u6210\u529f\u5b89\u88c5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u6d4b\u8bd5\u5b89\u88c5\u6210\u529f\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>\u8981\u6d4b\u8bd5 mysql \u5b89\u88c5\u662f\u5426\u6210\u529f\uff0c\u8bf7\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u68c0\u67e5\u670d\u52a1\u72b6\u6001\uff08mysql -u root -p\uff09\u521b\u5efa\u6d4b\u8bd5\u6570\u636e\u5e93\uff08create database testdb;\uff09\u9009\u62e9\u6d4b\u8bd5\u6570\u636e\u5e93\uff08use testdb;\uff09\u521b\u5efa\u6d4b\u8bd5\u8868\uff08create table test_table (id int not null auto_increment, name varchar(255), primary key (id));\uff09\u63d2\u5165\u6d4b\u8bd5\u6570\u636e\uff08insert into test_table (name) values (&#8216;\u6d4b\u8bd5 \u5982\u4f55\u6d4b\u8bd5 MySQL \u5b89\u88c5\u6210\u529f \u5b89\u88c5 MySQL \u540e\uff0c\u6d4b\u8bd5\u5176\u662f\u5426\u6210\u529f\u81f3\u5173\u91cd\u8981\u3002\u4ee5\u4e0b\u6b65\u9aa4\u5c06\u6307\u5bfc\u60a8\u9a8c\u8bc1\u5b89\u88c5\uff1a 1. \u68c0\u67e5 MySQL \u670d\u52a1\u72b6\u6001 \u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff08\u5982 CMD \u6216 Terminal\uff09 \u952e\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a mysql -u root -p \u767b\u5f55\u540e\u590d\u5236 \u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u8f93\u5165\u5bc6\u7801\u3002\u8f93\u5165\u60a8\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u7684 root \u5bc6\u7801\u3002 \u6210\u529f\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u540e\uff0c\u60a8\u5c06\u770b\u5230 MySQL \u63d0\u793a\u7b26\u3002 2. [&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-6170","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6170","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=6170"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6170\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6170"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}