{"id":53041,"date":"2024-10-09T07:48:15","date_gmt":"2024-10-08T23:48:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/53041\/"},"modified":"2024-11-14T10:36:22","modified_gmt":"2024-11-14T02:36:22","slug":"%e8%99%9b%e6%93%ac%e6%a9%9f-ubuntu-16-04-%e5%ae%89%e8%a3%9d-mysql-%e4%b8%bb%e6%a9%9f%e9%85%8d%e7%bd%ae%e8%a8%aa%e5%95%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/53041\/","title":{"rendered":"\u865b\u64ec\u6a5f Ubuntu 16.04 \u5b89\u88dd MySQL \u4e3b\u6a5f\u914d\u7f6e\u8a2a\u554f"},"content":{"rendered":"<h1 id=\"%e8%99%9b%e6%93%ac%e6%a9%9f-ubuntu-16-04-%e5%ae%89%e8%a3%9d-mysql-%e4%b8%bb%e6%a9%9f%e9%85%8d%e7%bd%ae%e8%a8%aa%e5%95%8f-rzCLKzpxYM\">\u865b\u64ec\u6a5f Ubuntu 16.04 \u5b89\u88dd MySQL \u4e3b\u6a5f\u914d\u7f6e\u8a2a\u554f<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u4e16\u754c\u4e2d\uff0cMySQL \u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u5404\u7a2e\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002\u672c\u6587\u5c07\u6307\u5c0e\u60a8\u5982\u4f55\u5728\u865b\u64ec\u6a5f\u4e0a\u5b89\u88dd Ubuntu 16.04 \u4e26\u914d\u7f6e MySQL \u4e3b\u6a5f\u8a2a\u554f\uff0c\u8b93\u60a8\u80fd\u5920\u6709\u6548\u5730\u7ba1\u7406\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e5%89%8d%e6%9c%9f%e6%ba%96%e5%82%99-rzCLKzpxYM\">\u524d\u671f\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u60a8\u7684\u865b\u64ec\u6a5f\u5df2\u7d93\u5b89\u88dd\u4e86 Ubuntu 16.04\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u865b\u64ec\u5316\u5e73\u53f0\uff0c\u5982 VMware\u3001VirtualBox \u6216 KVM\u3002\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u8acb\u78ba\u4fdd\u60a8\u7684\u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo apt update\nsudo apt upgrade<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-mysql-rzCLKzpxYM\">\u5b89\u88dd MySQL<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u5c07\u5b89\u88dd MySQL\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd MySQL \u4f3a\u670d\u5668\uff1a<\/p>\n<pre><code>sudo apt install mysql-server<\/code><\/pre>\n<p>\u5b89\u88dd\u904e\u7a0b\u4e2d\uff0c\u7cfb\u7d71\u6703\u63d0\u793a\u60a8\u8a2d\u7f6e MySQL \u7684 root \u5bc6\u78bc\u3002\u8acb\u52d9\u5fc5\u8a18\u4f4f\u9019\u500b\u5bc6\u78bc\uff0c\u56e0\u70ba\u60a8\u5c07\u9700\u8981\u5b83\u4f86\u8a2a\u554f MySQL \u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%ae-mysql-rzCLKzpxYM\">\u914d\u7f6e MySQL<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u904b\u884c MySQL \u5b89\u5168\u6027\u8173\u672c\uff0c\u4ee5\u63d0\u9ad8 MySQL \u7684\u5b89\u5168\u6027\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5\u5b89\u5168\u6027\u8173\u672c\uff1a<\/p>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<p>\u9019\u500b\u8173\u672c\u6703\u5f15\u5c0e\u60a8\u5b8c\u6210\u4e00\u4e9b\u5b89\u5168\u6027\u8a2d\u7f6e\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u8a2d\u7f6e root \u5bc6\u78bc<\/li>\n<li>\u522a\u9664\u533f\u540d\u7528\u6236<\/li>\n<li>\u7981\u6b62 root \u9060\u7a0b\u767b\u9304<\/li>\n<li>\u522a\u9664\u6e2c\u8a66\u6578\u64da\u5eab<\/li>\n<li>\u91cd\u65b0\u52a0\u8f09\u6b0a\u9650\u8868<\/li>\n<\/ul>\n<h2 id=\"%e5%85%81%e8%a8%b1%e9%81%a0%e7%a8%8b%e8%a8%aa%e5%95%8f-rzCLKzpxYM\">\u5141\u8a31\u9060\u7a0b\u8a2a\u554f<\/h2>\n<p>\u9ed8\u8a8d\u60c5\u6cc1\u4e0b\uff0cMySQL \u53ea\u5141\u8a31\u672c\u5730\u8a2a\u554f\u3002\u5982\u679c\u60a8\u5e0c\u671b\u5f9e\u5176\u4ed6\u4e3b\u6a5f\u8a2a\u554f MySQL\uff0c\u60a8\u9700\u8981\u9032\u884c\u4e00\u4e9b\u914d\u7f6e\u3002\u9996\u5148\uff0c\u7de8\u8f2f MySQL \u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/mysql\/mysql.conf.d\/mysqld.cnf<\/code><\/pre>\n<p>\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>bind-address = 127.0.0.1<\/code><\/pre>\n<p>\u5c07\u5176\u66f4\u6539\u70ba\uff1a<\/p>\n<pre><code>bind-address = 0.0.0.0<\/code><\/pre>\n<p>\u9019\u6a23\u53ef\u4ee5\u5141\u8a31\u6240\u6709 IP \u5730\u5740\u8a2a\u554f MySQL\u3002\u4fdd\u5b58\u4e26\u9000\u51fa\u7de8\u8f2f\u5668\u3002<\/p>\n<h2 id=\"%e5%89%b5%e5%bb%ba%e7%94%a8%e6%88%b6%e4%b8%a6%e6%8e%88%e6%ac%8a-rzCLKzpxYM\">\u5275\u5efa\u7528\u6236\u4e26\u6388\u6b0a<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u5275\u5efa\u4e00\u500b\u7528\u6236\u4e26\u6388\u4e88\u5176\u8a2a\u554f\u6b0a\u9650\u3002\u9996\u5148\uff0c\u767b\u9304\u5230 MySQL\uff1a<\/p>\n<pre><code>sudo mysql -u root -p<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5275\u5efa\u4e00\u500b\u65b0\u7528\u6236\u4e26\u6388\u4e88\u5176\u8a2a\u554f\u6b0a\u9650\uff1a<\/p>\n<pre><code>CREATE USER 'newuser'@'%' IDENTIFIED BY 'password';\nGRANT ALL PRIVILEGES ON *.* TO 'newuser'@'%' WITH GRANT OPTION;\nFLUSH PRIVILEGES;<\/code><\/pre>\n<p>\u8acb\u5c07 &#8216;newuser&#8217; \u548c &#8216;password&#8217; \u66ff\u63db\u70ba\u60a8\u5e0c\u671b\u4f7f\u7528\u7684\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002<\/p>\n<h2 id=\"%e9%87%8d%e5%95%9f-mysql-%e6%9c%8d%e5%8b%99-rzCLKzpxYM\">\u91cd\u555f MySQL \u670d\u52d9<\/h2>\n<p>\u5b8c\u6210\u4e0a\u8ff0\u6b65\u9a5f\u5f8c\uff0c\u60a8\u9700\u8981\u91cd\u555f MySQL \u670d\u52d9\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart mysql<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%81%a0%e7%a8%8b%e8%a8%aa%e5%95%8f-rzCLKzpxYM\">\u6e2c\u8a66\u9060\u7a0b\u8a2a\u554f<\/h2>\n<p>\u6700\u5f8c\uff0c\u60a8\u53ef\u4ee5\u5f9e\u53e6\u4e00\u53f0\u4e3b\u6a5f\u4e0a\u6e2c\u8a66 MySQL \u7684\u9060\u7a0b\u8a2a\u554f\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>mysql -u newuser -h your_server_ip -p<\/code><\/pre>\n<p>\u5982\u679c\u4e00\u5207\u914d\u7f6e\u6b63\u78ba\uff0c\u60a8\u61c9\u8a72\u80fd\u5920\u6210\u529f\u767b\u9304\u5230 MySQL\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-rzCLKzpxYM\">\u7e3d\u7d50<\/h2>\n<p>\u672c\u6587\u4ecb\u7d39\u4e86\u5982\u4f55\u5728\u865b\u64ec\u6a5f Ubuntu 16.04 \u4e0a\u5b89\u88dd MySQL \u4e26\u914d\u7f6e\u4e3b\u6a5f\u8a2a\u554f\u3002\u901a\u904e\u9019\u4e9b\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u5730\u8a2d\u7f6e\u4e00\u500b\u5b89\u5168\u4e14\u53ef\u9060\u7a0b\u8a2a\u554f\u7684 MySQL \u6578\u64da\u5eab\u3002\u82e5\u60a8\u9700\u8981\u9032\u4e00\u6b65\u7684\u652f\u6301\u6216\u5c0b\u627e\u5408\u9069\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5728\u865b\u64ec\u6a5f\u4e0a\u7684 Ubuntu 16.04 \u4e2d\u5b89\u88dd MySQL\uff0c\u4e26\u914d\u7f6e\u4e3b\u6a5f\u4ee5\u4fbf\u9032\u884c\u9060\u7a0b\u8a2a\u554f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-53041","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53041","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=53041"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53041\/revisions"}],"predecessor-version":[{"id":53042,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/53041\/revisions\/53042"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=53041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=53041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=53041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}