{"id":59569,"date":"2024-10-12T23:03:14","date_gmt":"2024-10-12T15:03:14","guid":{"rendered":"https:\/\/server.hk\/cnblog\/59569\/"},"modified":"2024-10-12T23:03:14","modified_gmt":"2024-10-12T15:03:14","slug":"centos%e8%bc%95%e9%ac%86%e7%8d%b2%e5%8f%96%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e7%9a%84%e6%96%b9%e6%b3%95-centos%e6%9f%a5%e8%a9%a2%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/59569\/","title":{"rendered":"CentOS\u8f15\u9b06\u7372\u53d6\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u65b9\u6cd5 (centos\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc)"},"content":{"rendered":"<h1 id=\"centos%e8%bc%95%e9%ac%86%e7%8d%b2%e5%8f%96%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc%e7%9a%84%e6%96%b9%e6%b3%95-NLyBsBSCul\">CentOS\u8f15\u9b06\u7372\u53d6\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u65b9\u6cd5<\/h1>\n<p>\u5728\u4f7f\u7528CentOS\u4f5c\u696d\u7cfb\u7d71\u7684\u4f3a\u670d\u5668\u4e0a\uff0c\u7ba1\u7406\u6578\u64da\u5eab\u662f\u65e5\u5e38\u5de5\u4f5c\u4e2d\u4e0d\u53ef\u6216\u7f3a\u7684\u4e00\u90e8\u5206\u3002\u7121\u8ad6\u662fMySQL\u3001MariaDB\u9084\u662fPostgreSQL\uff0c\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u548c\u7ba1\u7406\u90fd\u81f3\u95dc\u91cd\u8981\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728CentOS\u4e0a\u8f15\u9b06\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u65b9\u6cd5\uff0c\u5e6b\u52a9\u7528\u6236\u66f4\u597d\u5730\u7ba1\u7406\u5176\u6578\u64da\u5eab\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e9%9c%80%e8%a6%81%e6%9f%a5%e8%a9%a2%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-NLyBsBSCul\">\u70ba\u4ec0\u9ebc\u9700\u8981\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc<\/h2>\n<p>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u7528\u6236\u53ef\u80fd\u6703\u5fd8\u8a18\u6578\u64da\u5eab\u7684\u5bc6\u78bc\uff0c\u6216\u8005\u9700\u8981\u5728\u4e0d\u540c\u7684\u61c9\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u76f8\u540c\u7684\u6578\u64da\u5eab\u9023\u63a5\u3002\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u80fd\u529b\u53ef\u4ee5\u5e6b\u52a9\u7528\u6236\u5feb\u901f\u6062\u5fa9\u8a2a\u554f\u6b0a\u9650\uff0c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u9ebb\u7169\u3002<\/p>\n<h2 id=\"%e6%9f%a5%e8%a9%a2mysql-mariadb%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-NLyBsBSCul\">\u67e5\u8a62MySQL\/MariaDB\u6578\u64da\u5eab\u5bc6\u78bc<\/h2>\n<p>\u5c0d\u65bcMySQL\u6216MariaDB\u7528\u6236\uff0c\u6578\u64da\u5eab\u5bc6\u78bc\u901a\u5e38\u5b58\u5132\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002\u4ee5\u4e0b\u662f\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6-NLyBsBSCul\">1. \u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6<\/h3>\n<p>MySQL\u548cMariaDB\u7684\u914d\u7f6e\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc\u4ee5\u4e0b\u8def\u5f91\uff1a<\/p>\n<pre><code>\/etc\/my.cnf\n\/etc\/mysql\/my.cnf\n<\/code><\/pre>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u958b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/my.cnf\n<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u67e5\u627e\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code>[client]\nuser=your_username\npassword=your_password\n<\/code><\/pre>\n<p>\u5982\u679c\u5bc6\u78bc\u4ee5\u660e\u6587\u5f62\u5f0f\u986f\u793a\uff0c\u5247\u53ef\u4ee5\u76f4\u63a5\u67e5\u770b\u3002\u5982\u679c\u5bc6\u78bc\u672a\u986f\u793a\uff0c\u5247\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u65b9\u6cd5\u4f86\u91cd\u7f6e\u5bc6\u78bc\u3002<\/p>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e8%a1%8c%e9%87%8d%e7%bd%ae%e5%af%86%e7%a2%bc-NLyBsBSCul\">2. \u4f7f\u7528\u547d\u4ee4\u884c\u91cd\u7f6e\u5bc6\u78bc<\/h3>\n<p>\u5982\u679c\u7121\u6cd5\u627e\u5230\u5bc6\u78bc\uff0c\u53ef\u4ee5\u901a\u904e\u547d\u4ee4\u884c\u91cd\u7f6e\u5bc6\u78bc\u3002\u4ee5\u4e0b\u662f\u91cd\u7f6eMySQL\/MariaDB\u5bc6\u78bc\u7684\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo systemctl stop mysqld\nsudo mysqld_safe --skip-grant-tables &amp;\nmysql -u root\n<\/code><\/pre>\n<p>\u9032\u5165MySQL\u5f8c\uff0c\u57f7\u884c\u4ee5\u4e0b\u547d\u4ee4\u4f86\u91cd\u7f6e\u5bc6\u78bc\uff1a<\/p>\n<pre><code>FLUSH PRIVILEGES;\nALTER USER 'your_username'@'localhost' IDENTIFIED BY 'new_password';\n<\/code><\/pre>\n<p>\u5b8c\u6210\u5f8c\uff0c\u9000\u51faMySQL\u4e26\u91cd\u555f\u670d\u52d9\uff1a<\/p>\n<pre><code>exit\nsudo systemctl start mysqld\n<\/code><\/pre>\n<h2 id=\"%e6%9f%a5%e8%a9%a2postgresql%e6%95%b8%e6%93%9a%e5%ba%ab%e5%af%86%e7%a2%bc-NLyBsBSCul\">\u67e5\u8a62PostgreSQL\u6578\u64da\u5eab\u5bc6\u78bc<\/h2>\n<p>\u5c0d\u65bcPostgreSQL\u7528\u6236\uff0c\u6578\u64da\u5eab\u5bc6\u78bc\u901a\u5e38\u5b58\u5132\u5728pg_hba.conf\u6587\u4ef6\u4e2d\u3002\u4ee5\u4e0b\u662f\u67e5\u8a62PostgreSQL\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5pg_hba-conf%e6%96%87%e4%bb%b6-NLyBsBSCul\">1. \u6aa2\u67e5pg_hba.conf\u6587\u4ef6<\/h3>\n<p>pg_hba.conf\u6587\u4ef6\u901a\u5e38\u4f4d\u65bc\u4ee5\u4e0b\u8def\u5f91\uff1a<\/p>\n<pre><code>\/etc\/postgresql\/{version}\/main\/pg_hba.conf\n<\/code><\/pre>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u958b\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo nano \/etc\/postgresql\/{version}\/main\/pg_hba.conf\n<\/code><\/pre>\n<p>\u5728\u6587\u4ef6\u4e2d\u67e5\u627e\u7528\u6236\u7684\u9023\u63a5\u8a2d\u7f6e\uff0c\u9019\u88e1\u4e0d\u6703\u986f\u793a\u5bc6\u78bc\uff0c\u4f46\u53ef\u4ee5\u78ba\u8a8d\u7528\u6236\u7684\u9023\u63a5\u65b9\u5f0f\u3002<\/p>\n<h3 id=\"2-%e4%bd%bf%e7%94%a8%e5%91%bd%e4%bb%a4%e8%a1%8c%e9%87%8d%e7%bd%ae%e5%af%86%e7%a2%bc-NLyBsBSCul\">2. \u4f7f\u7528\u547d\u4ee4\u884c\u91cd\u7f6e\u5bc6\u78bc<\/h3>\n<p>\u5982\u679c\u7121\u6cd5\u627e\u5230\u5bc6\u78bc\uff0c\u53ef\u4ee5\u901a\u904e\u547d\u4ee4\u884c\u91cd\u7f6e\u5bc6\u78bc\u3002\u4ee5\u4e0b\u662f\u91cd\u7f6ePostgreSQL\u5bc6\u78bc\u7684\u6b65\u9a5f\uff1a<\/p>\n<pre><code>sudo -u postgres psql\nALTER USER your_username WITH PASSWORD 'new_password';\n<\/code><\/pre>\n<p>\u5b8c\u6210\u5f8c\uff0c\u9000\u51faPostgreSQL\uff1a<\/p>\n<pre><code>exit\n<\/code><\/pre>\n<h2 id=\"%e7%b8%bd%e7%b5%90-NLyBsBSCul\">\u7e3d\u7d50<\/h2>\n<p>\u5728CentOS\u4e0a\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u65b9\u6cd5\u4e3b\u8981\u4f9d\u8cf4\u65bc\u6aa2\u67e5\u914d\u7f6e\u6587\u4ef6\u548c\u4f7f\u7528\u547d\u4ee4\u884c\u91cd\u7f6e\u5bc6\u78bc\u3002\u7121\u8ad6\u662fMySQL\u3001MariaDB\u9084\u662fPostgreSQL\uff0c\u4e86\u89e3\u5982\u4f55\u7ba1\u7406\u6578\u64da\u5eab\u5bc6\u78bc\u5c0d\u65bc\u78ba\u4fdd\u6578\u64da\u5eab\u7684\u5b89\u5168\u6027\u81f3\u95dc\u91cd\u8981\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7ba1\u7406\u548c\u4f3a\u670d\u5668\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528<a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a>\u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u696d\u52d9\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u5728CentOS\u4e0a\u8f15\u9b06\u67e5\u8a62\u6578\u64da\u5eab\u5bc6\u78bc\u7684\u65b9\u6cd5\uff0c\u5feb\u901f\u7372\u53d6\u6240\u9700\u7684\u6578\u64da\u5eab\u8a2a\u554f\u6191\u8b49\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-59569","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/59569","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=59569"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/59569\/revisions"}],"predecessor-version":[{"id":59570,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/59569\/revisions\/59570"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=59569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=59569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=59569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}