{"id":174965,"date":"2024-11-08T01:15:21","date_gmt":"2024-11-07T17:15:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/174965\/"},"modified":"2024-11-08T01:15:22","modified_gmt":"2024-11-07T17:15:22","slug":"%e5%a6%82%e4%bd%95%e7%a2%ba%e8%aa%8dsql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b7%b2%e5%ae%89%e8%a3%9d%e7%a8%8b%e5%ba%8f-sql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b7%b2%e5%ae%89%e8%a3%9d%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/174965\/","title":{"rendered":"\u5982\u4f55\u78ba\u8a8dSQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f (sql\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f)"},"content":{"rendered":"<h1 id=\"%e5%a6%82%e4%bd%95%e7%a2%ba%e8%aa%8dsql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b7%b2%e5%ae%89%e8%a3%9d%e7%a8%8b%e5%ba%8f-sql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%b7%b2%e5%ae%89%e8%a3%9d%e7%a8%8b%e5%ba%8f-KAFxcstReT\">\u5982\u4f55\u78ba\u8a8dSQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f (SQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f)<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0cSQL\u6578\u64da\u5eab\u662f\u8a31\u591a\u61c9\u7528\u7a0b\u5e8f\u548c\u7db2\u7ad9\u7684\u6838\u5fc3\u7d44\u4ef6\u3002\u7121\u8ad6\u662f\u7528\u65bc\u5b58\u5132\u7528\u6236\u6578\u64da\u3001\u4ea4\u6613\u8a18\u9304\u9084\u662f\u5176\u4ed6\u91cd\u8981\u4fe1\u606f\uff0c\u78ba\u4fddSQL\u6578\u64da\u5eab\u7684\u6b63\u78ba\u5b89\u88dd\u548c\u914d\u7f6e\u81f3\u95dc\u91cd\u8981\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u78ba\u8a8dSQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f\uff0c\u4e26\u63d0\u4f9b\u4e00\u4e9b\u5be6\u7528\u7684\u6b65\u9a5f\u548c\u793a\u4f8b\u3002<\/p>\n<h2 id=\"1-%e7%a2%ba%e8%aa%8d%e5%ae%89%e8%a3%9d%e7%9a%84sql%e6%95%b8%e6%93%9a%e5%ba%ab%e9%a1%9e%e5%9e%8b-KAFxcstReT\">1. \u78ba\u8a8d\u5b89\u88dd\u7684SQL\u6578\u64da\u5eab\u985e\u578b<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u78ba\u5b9a\u60a8\u6240\u4f7f\u7528\u7684SQL\u6578\u64da\u5eab\u985e\u578b\u3002\u5e38\u898b\u7684SQL\u6578\u64da\u5eab\u5305\u62ec\uff1a<\/p>\n<ul>\n<li id=\"mysql-KAFxcstReT\">MySQL<\/li>\n<li id=\"postgresql-KAFxcstReT\">PostgreSQL<\/li>\n<li id=\"microsoft-sql-server-KAFxcstReT\">Microsoft SQL Server<\/li>\n<li>SQLite<\/li>\n<\/ul>\n<p>\u6bcf\u7a2e\u6578\u64da\u5eab\u7684\u5b89\u88dd\u548c\u78ba\u8a8d\u65b9\u6cd5\u53ef\u80fd\u6703\u6709\u6240\u4e0d\u540c\uff0c\u56e0\u6b64\u4e86\u89e3\u60a8\u6b63\u5728\u4f7f\u7528\u7684\u6578\u64da\u5eab\u985e\u578b\u662f\u7b2c\u4e00\u6b65\u3002<\/p>\n<h2 id=\"2-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e5%ba%ab%e6%9c%8d%e5%8b%99%e7%8b%80%e6%85%8b-KAFxcstReT\">2. \u6aa2\u67e5\u6578\u64da\u5eab\u670d\u52d9\u72c0\u614b<\/h2>\n<p>\u5728\u78ba\u8a8dSQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6aa2\u67e5\u6578\u64da\u5eab\u670d\u52d9\u662f\u5426\u6b63\u5728\u904b\u884c\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u6578\u64da\u5eab\u7684\u6aa2\u67e5\u65b9\u6cd5\uff1a<\/p>\n<h3 id=\"mysql-KAFxcstReT\">MySQL<\/h3>\n<pre><code>sudo systemctl status mysql<\/code><\/pre>\n<h3 id=\"postgresql-KAFxcstReT\">PostgreSQL<\/h3>\n<pre><code>sudo systemctl status postgresql<\/code><\/pre>\n<h3 id=\"microsoft-sql-server-KAFxcstReT\">Microsoft SQL Server<\/h3>\n<pre><code>systemctl status mssql-server<\/code><\/pre>\n<p>\u9019\u4e9b\u547d\u4ee4\u5c07\u986f\u793a\u6578\u64da\u5eab\u670d\u52d9\u7684\u7576\u524d\u72c0\u614b\u3002\u5982\u679c\u670d\u52d9\u6b63\u5728\u904b\u884c\uff0c\u60a8\u5c07\u770b\u5230\u201cactive (running)\u201d\u7684\u72c0\u614b\u3002<\/p>\n<h2 id=\"3-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e8%a1%8c%e5%b7%a5%e5%85%b7%e9%80%a3%e6%8e%a5%e6%95%b8%e6%93%9a%e5%ba%ab-KAFxcstReT\">3. \u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u9023\u63a5\u6578\u64da\u5eab<\/h2>\n<p>\u78ba\u8a8d\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7684\u53e6\u4e00\u7a2e\u65b9\u6cd5\u662f\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u9023\u63a5\u5230\u6578\u64da\u5eab\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<h3 id=\"mysql-KAFxcstReT\">MySQL<\/h3>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<h3 id=\"postgresql-KAFxcstReT\">PostgreSQL<\/h3>\n<pre><code>psql -U postgres<\/code><\/pre>\n<h3 id=\"microsoft-sql-server-KAFxcstReT\">Microsoft SQL Server<\/h3>\n<pre><code>sqlcmd -S localhost -U SA -P 'your_password'<\/code><\/pre>\n<p>\u6210\u529f\u9023\u63a5\u5f8c\uff0c\u60a8\u5c07\u9032\u5165\u6578\u64da\u5eab\u7684\u547d\u4ee4\u884c\u754c\u9762\uff0c\u9019\u8868\u660e\u6578\u64da\u5eab\u5df2\u6b63\u78ba\u5b89\u88dd\u3002<\/p>\n<h2 id=\"4-%e6%aa%a2%e6%9f%a5%e6%95%b8%e6%93%9a%e5%ba%ab%e7%89%88%e6%9c%ac-KAFxcstReT\">4. \u6aa2\u67e5\u6578\u64da\u5eab\u7248\u672c<\/h2>\n<p>\u78ba\u8a8d\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7684\u53e6\u4e00\u500b\u6307\u6a19\u662f\u6aa2\u67e5\u5176\u7248\u672c\u3002\u9019\u53ef\u4ee5\u5e6b\u52a9\u60a8\u78ba\u4fdd\u60a8\u4f7f\u7528\u7684\u662f\u6700\u65b0\u7248\u672c\uff0c\u4e26\u4e14\u53ef\u4ee5\u5229\u7528\u6700\u65b0\u7684\u529f\u80fd\u548c\u5b89\u5168\u6027\u4fee\u88dc\u3002\u4ee5\u4e0b\u662f\u6aa2\u67e5\u7248\u672c\u7684\u547d\u4ee4\uff1a<\/p>\n<h3 id=\"mysql-KAFxcstReT\">MySQL<\/h3>\n<pre><code>mysql -V<\/code><\/pre>\n<h3 id=\"postgresql-KAFxcstReT\">PostgreSQL<\/h3>\n<pre><code>psql --version<\/code><\/pre>\n<h3 id=\"microsoft-sql-server-KAFxcstReT\">Microsoft SQL Server<\/h3>\n<pre><code>sqlcmd -S localhost -U SA -P 'your_password' -Q \"SELECT @@VERSION\"<\/code><\/pre>\n<p>\u9019\u4e9b\u547d\u4ee4\u5c07\u986f\u793a\u7576\u524d\u5b89\u88dd\u7684\u6578\u64da\u5eab\u7248\u672c\u3002<\/p>\n<h2 id=\"5-%e6%b8%ac%e8%a9%a6%e6%95%b8%e6%93%9a%e5%ba%ab%e5%8a%9f%e8%83%bd-KAFxcstReT\">5. \u6e2c\u8a66\u6578\u64da\u5eab\u529f\u80fd<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u5275\u5efa\u4e00\u500b\u7c21\u55ae\u7684\u6578\u64da\u5eab\u548c\u8868\u4f86\u6e2c\u8a66\u6578\u64da\u5eab\u7684\u529f\u80fd\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\uff1a<\/p>\n<h3 id=\"mysql-KAFxcstReT\">MySQL<\/h3>\n<pre><code>CREATE DATABASE test_db;\nUSE test_db;\nCREATE TABLE test_table (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255));\nINSERT INTO test_table (name) VALUES ('Test Name');\nSELECT * FROM test_table;<\/code><\/pre>\n<h3 id=\"postgresql-KAFxcstReT\">PostgreSQL<\/h3>\n<pre><code>CREATE DATABASE test_db;\nc test_db\nCREATE TABLE test_table (id SERIAL PRIMARY KEY, name VARCHAR(255));\nINSERT INTO test_table (name) VALUES ('Test Name');\nSELECT * FROM test_table;<\/code><\/pre>\n<p>\u9019\u4e9b\u64cd\u4f5c\u5c07\u5e6b\u52a9\u60a8\u78ba\u8a8d\u6578\u64da\u5eab\u7684\u57fa\u672c\u529f\u80fd\u662f\u5426\u6b63\u5e38\u904b\u4f5c\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-KAFxcstReT\">\u7e3d\u7d50<\/h2>\n<p>\u78ba\u8a8dSQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f\u662f\u4e00\u500b\u91cd\u8981\u7684\u6b65\u9a5f\uff0c\u78ba\u4fdd\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\u80fd\u5920\u6b63\u5e38\u904b\u884c\u3002\u901a\u904e\u6aa2\u67e5\u670d\u52d9\u72c0\u614b\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u9023\u63a5\u6578\u64da\u5eab\u3001\u6aa2\u67e5\u7248\u672c\u4ee5\u53ca\u6e2c\u8a66\u6578\u64da\u5eab\u529f\u80fd\uff0c\u60a8\u53ef\u4ee5\u78ba\u4fdd\u60a8\u7684SQL\u6578\u64da\u5eab\u5df2\u6b63\u78ba\u5b89\u88dd\u4e26\u904b\u884c\u3002\u5982\u679c\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u9ad8\u6548\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u6216<a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a>\u4f86\u6258\u7ba1\u60a8\u7684\u6578\u64da\u5eab\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u696d\u52d9\u63d0\u4f9b\u7a69\u5b9a\u548c\u5b89\u5168\u7684\u74b0\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u78ba\u8a8dSQL\u6578\u64da\u5eab\u5df2\u5b89\u88dd\u7a0b\u5e8f\uff0c\u5305\u62ec\u6aa2\u67e5\u5b89\u88dd\u72c0\u614b\u3001\u7248\u672c\u548c\u914d\u7f6e\u8a2d\u5b9a\u7684\u6b65\u9a5f\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-174965","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174965","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"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=174965"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174965\/revisions"}],"predecessor-version":[{"id":174966,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/174965\/revisions\/174966"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=174965"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=174965"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=174965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}