{"id":76678,"date":"2024-10-16T08:54:15","date_gmt":"2024-10-16T00:54:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/76678\/"},"modified":"2024-10-16T08:54:15","modified_gmt":"2024-10-16T00:54:15","slug":"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%9c%a8archlinux%e7%9a%84%e5%ae%89%e8%a3%9d%e5%92%8c%e5%95%9f%e5%8b%95%e5%8c%af%e7%b8%bd","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/76678\/","title":{"rendered":"MySQL\u6578\u64da\u5eab\u5728ArchLinux\u7684\u5b89\u88dd\u548c\u555f\u52d5\u532f\u7e3d"},"content":{"rendered":"<h1 id=\"mysql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%9c%a8archlinux%e7%9a%84%e5%ae%89%e8%a3%9d%e5%92%8c%e5%95%9f%e5%8b%95%e5%8c%af%e7%b8%bd-xJbmnQPvFw\">MySQL\u6578\u64da\u5eab\u5728ArchLinux\u7684\u5b89\u88dd\u548c\u555f\u52d5\u532f\u7e3d<\/h1>\n<p>MySQL\u662f\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u95dc\u806f\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728ArchLinux\u4e0a\u5b89\u88dd\u548c\u555f\u52d5MySQL\u6578\u64da\u5eab\uff0c\u5e6b\u52a9\u7528\u6236\u5feb\u901f\u4e0a\u624b\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dmysql-xJbmnQPvFw\">\u5b89\u88ddMySQL<\/h2>\n<p>\u5728ArchLinux\u4e0a\u5b89\u88ddMySQL\u975e\u5e38\u7c21\u55ae\uff0c\u4f7f\u7528\u5305\u7ba1\u7406\u5668pacman\u5373\u53ef\u5b8c\u6210\u3002\u9996\u5148\uff0c\u6253\u958b\u7d42\u7aef\u4e26\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo pacman -S mysql<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u5c07\u6703\u4e0b\u8f09\u4e26\u5b89\u88ddMySQL\u53ca\u5176\u4f9d\u8cf4\u9805\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u521d\u59cb\u5316MySQL\u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>sudo mysql_install_db --user=mysql --basedir=\/usr --datadir=\/var\/lib\/mysql<\/code><\/pre>\n<p>\u9019\u689d\u547d\u4ee4\u6703\u5275\u5efaMySQL\u6240\u9700\u7684\u6578\u64da\u76ee\u9304\u548c\u7cfb\u7d71\u8868\u3002<\/p>\n<h2 id=\"%e5%95%9f%e5%8b%95mysql%e6%9c%8d%e5%8b%99-xJbmnQPvFw\">\u555f\u52d5MySQL\u670d\u52d9<\/h2>\n<p>\u5b89\u88dd\u548c\u521d\u59cb\u5316\u5b8c\u6210\u5f8c\uff0c\u63a5\u4e0b\u4f86\u9700\u8981\u555f\u52d5MySQL\u670d\u52d9\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u555f\u7528MySQL\u670d\u52d9\uff0c\u4ee5\u4fbf\u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff1a<\/p>\n<pre><code>sudo systemctl enable mysqld<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5MySQL\u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl start mysqld<\/code><\/pre>\n<p>\u8981\u6aa2\u67e5MySQL\u670d\u52d9\u7684\u72c0\u614b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo systemctl status mysqld<\/code><\/pre>\n<p>\u5982\u679c\u670d\u52d9\u904b\u884c\u6b63\u5e38\uff0c\u60a8\u61c9\u8a72\u6703\u770b\u5230\u985e\u4f3c\u65bc\u201cactive (running)\u201d\u7684\u72c0\u614b\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%aemysql-xJbmnQPvFw\">\u914d\u7f6eMySQL<\/h2>\n<p>\u555f\u52d5MySQL\u670d\u52d9\u5f8c\uff0c\u60a8\u9700\u8981\u9032\u884c\u4e00\u4e9b\u57fa\u672c\u914d\u7f6e\u3002\u9996\u5148\uff0c\u904b\u884c\u5b89\u5168\u6027\u8173\u672c\u4ee5\u63d0\u9ad8MySQL\u7684\u5b89\u5168\u6027\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>\u9019\u500b\u8173\u672c\u5c07\u5f15\u5c0e\u60a8\u5b8c\u6210\u4e00\u4e9b\u5b89\u5168\u8a2d\u7f6e\uff0c\u5305\u62ec\u8a2d\u7f6eroot\u5bc6\u78bc\u3001\u522a\u9664\u533f\u540d\u7528\u6236\u3001\u7981\u6b62root\u9060\u7a0b\u767b\u9304\u7b49\u3002\u6839\u64da\u63d0\u793a\u9032\u884c\u64cd\u4f5c\u5373\u53ef\u3002<\/p>\n<h2 id=\"%e9%80%a3%e6%8e%a5%e5%88%b0mysql-xJbmnQPvFw\">\u9023\u63a5\u5230MySQL<\/h2>\n<p>\u914d\u7f6e\u5b8c\u6210\u5f8c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9023\u63a5\u5230MySQL\u6578\u64da\u5eab\uff1a<\/p>\n<pre><code>mysql -u root -p<\/code><\/pre>\n<p>\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8f38\u5165\u5bc6\u78bc\uff0c\u8f38\u5165\u60a8\u5728\u5b89\u5168\u6027\u8173\u672c\u4e2d\u8a2d\u7f6e\u7684root\u5bc6\u78bc\u5f8c\uff0c\u5373\u53ef\u9032\u5165MySQL\u547d\u4ee4\u884c\u754c\u9762\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e7%94%a8mysql%e5%91%bd%e4%bb%a4-xJbmnQPvFw\">\u5e38\u7528MySQL\u547d\u4ee4<\/h2>\n<p>\u5728MySQL\u547d\u4ee4\u884c\u754c\u9762\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u5e38\u7528\u547d\u4ee4\u4f86\u7ba1\u7406\u6578\u64da\u5eab\uff1a<\/p>\n<ul>\n<li><code>SHOW DATABASES;<\/code> &#8211; \u986f\u793a\u6240\u6709\u6578\u64da\u5eab\u3002<\/li>\n<li><code>CREATE DATABASE database_name;<\/code> &#8211; \u5275\u5efa\u65b0\u6578\u64da\u5eab\u3002<\/li>\n<li><code>USE database_name;<\/code> &#8211; \u5207\u63db\u5230\u6307\u5b9a\u6578\u64da\u5eab\u3002<\/li>\n<li><code>SHOW TABLES;<\/code> &#8211; \u986f\u793a\u7576\u524d\u6578\u64da\u5eab\u4e2d\u7684\u6240\u6709\u8868\u3002<\/li>\n<li><code>DROP DATABASE database_name;<\/code> &#8211; \u522a\u9664\u6307\u5b9a\u6578\u64da\u5eab\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-xJbmnQPvFw\">\u7e3d\u7d50<\/h2>\n<p>\u5728ArchLinux\u4e0a\u5b89\u88dd\u548c\u555f\u52d5MySQL\u6578\u64da\u5eab\u7684\u904e\u7a0b\u76f8\u5c0d\u7c21\u55ae\uff0c\u901a\u904e\u4f7f\u7528pacman\u5305\u7ba1\u7406\u5668\u548csystemctl\u670d\u52d9\u7ba1\u7406\u5de5\u5177\uff0c\u60a8\u53ef\u4ee5\u5feb\u901f\u5b8c\u6210\u5b89\u88dd\u548c\u914d\u7f6e\u3002\u7121\u8ad6\u662f\u958b\u767c\u74b0\u5883\u9084\u662f\u751f\u7522\u74b0\u5883\uff0cMySQL\u90fd\u662f\u4e00\u500b\u5f37\u5927\u7684\u6578\u64da\u5eab\u9078\u64c7\u3002\u5982\u679c\u60a8\u9700\u8981\u7a69\u5b9a\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u4f86\u904b\u884c\u60a8\u7684\u61c9\u7528\u7a0b\u5e8f\uff0cServer.HK\u63d0\u4f9b\u591a\u7a2e <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u6eff\u8db3\u4e0d\u540c\u7528\u6236\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3\u5982\u4f55\u5728ArchLinux\u4e0a\u5b89\u88dd\u548c\u555f\u52d5MySQL\u6578\u64da\u5eab\uff0c\u7c21\u55ae\u6b65\u9a5f\u548c\u6280\u5de7\uff0c\u52a9\u60a8\u5feb\u901f\u4e0a\u624b\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-76678","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76678","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=76678"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76678\/revisions"}],"predecessor-version":[{"id":76679,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/76678\/revisions\/76679"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=76678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=76678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=76678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}