{"id":31,"date":"2015-05-14T16:15:44","date_gmt":"2015-05-14T08:15:44","guid":{"rendered":"http:\/\/yyshell.com\/?p=31"},"modified":"2015-05-14T16:15:44","modified_gmt":"2015-05-14T08:15:44","slug":"%e8%ae%b0%e4%b8%80%e6%ac%a1%e6%95%b0%e6%8d%ae%e5%ba%93%e6%95%b0%e6%8d%ae%e7%9b%ae%e5%bd%95%e8%bf%81%e7%a7%bb%e8%bf%87%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/yyshell.com\/?p=31","title":{"rendered":"\u8bb0\u4e00\u6b21\u6570\u636e\u5e93\u6570\u636e\u76ee\u5f55\u8fc1\u79fb\u8fc7\u7a0b"},"content":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\uff0c\u53bb<a href=\"http:\/\/www.chinanet.cc\/\" target=\"_blank\">\u4e2d\u7f51\u79d1\u6280<\/a>\u5f00\u901a\u4e86\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\uff0clinux\u7cfb\u7edf\uff0c\u5b89\u88c5\u4e86LEMP\u73af\u5883\uff08\u6570\u636e\u5e93\u7528\u7684\u662fmariadb\uff09\uff0c\u8dd1\u7f51\u7ad9\u611f\u89c9\u901f\u5ea6\u975e\u5e38\u6d41\u7545\uff0c\u6bd4\u8f83\u6ee1\u610f\u3002\u7528\u4e86\u4e00\u6bb5\u65f6\u95f4\u4e4b\u540e\uff0c\u7a81\u7136\u60f3\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u867d\u7136\u6211\u7684\u7f51\u7ad9\u7a0b\u5e8f\u5728\u7b2c\u4e8c\u5757\u78c1\u76d8\u4e0a\uff0c\u4e07\u4e00\u54ea\u5929\u7cfb\u7edf\u5954\u6e83\u4e86\uff0c\u6211\u7684\u7f51\u7ad9\u6570\u636e\u662f\u4e0d\u4f1a\u4e22\uff0c\u4f46\u662f\u6211\u4eec\u6570\u636e\u5e93\u5728\u7cfb\u7edf\u76d8\uff0c\u4e5f\u5c31\u662fsda\u8bbe\u5907\u4e0a\uff0c\u90a3\u6211\u5230\u65f6\u5019\u60f3\u91cd\u88c5\u7cfb\u7edf\uff0c\u6570\u636e\u5e93\u5c82\u4e0d\u5b8c\u86cb\uff0c\u8d76\u7d27\u60f3\u529e\u6cd5\u8fc1\u79fb\u6570\u636e\u5e93\u5230sdb\u78c1\u76d8\u4e0a\u9762\u3002<\/p>\n<p>\u4f17\u6240\u5468\u77e5\uff0cMySQL\uff08MariaDB\uff09\u4e00\u822c\u4f7f\u7528<strong> \/<\/strong>var\/lib\/mysql \u76ee\u5f55\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u6570\u636e\u5b58\u50a8\u76ee\u5f55\uff0c\u9ed8\u8ba4\u7684\u914d\u7f6e\u6587\u4ef6\u4e3a\/etc\/my.cnf\u3002\u65e2\u7136\u8981\u5f00\u59cb\u8fc1\u79fb\uff0c\u5148\u628a\u6570\u636e\u5e93\u505c\u4e86\u518d\u8bf4\uff1a<\/p>\n<pre class=\"lang:default decode:true \">[root@localhost wordpress]# systemctl stop mariadb.service<\/pre>\n<p>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:default decode:true \">[root@localhost wordpress]# vim \/etc\/my.cnf<\/pre>\n<p>\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true \">[mysqld]\r\ndatadir=\/var\/lib\/mysql\r\nsocket=\/var\/lib\/mysql\/mysql.sock\r\n# Disabling symbolic-links is recommended to prevent assorted security risks\r\nsymbolic-links=0\r\n# Settings user and group are ignored when systemd is used.\r\n# If you need to run mysqld under a different user or group,\r\n# customize your systemd unit file for mariadb according to the\r\n# instructions in http:\/\/fedoraproject.org\/wiki\/Systemd\r\n\r\n[mysqld_safe]\r\nlog-error=\/var\/log\/mariadb\/mariadb.log\r\npid-file=\/var\/run\/mariadb\/mariadb.pid\r\n\r\n#\r\n# include all files from the config directory\r\n#\r\n!includedir \/etc\/my.cnf.d<\/pre>\n<p>\u628a\u5176\u4e2d\u7684datadir\u548csocket\u90fd\u6ce8\u91ca\u6389\uff0c\u6539\u6210\u65b0\u7684\u76ee\u5f55\u4f4d\u7f6edatadir=\/mnt\/sdb\/mysql\uff0csocket=\/mnt\/sdb\/mysql\/mysql.sock\uff0c\u521b\u5efa\u76f8\u5e94\u76ee\u5f55\u65f6\uff0c\u8bb0\u5f97\u8bbe\u7f6e\u76f8\u5e94\u7684\u6743\u9650\u548c\u6240\u6709\u8005\uff0c\u5e76\u4e14\u8981\u6ce8\u610fselinux\u4e0a\u4e0b\u6587\u7684\u8bbe\u7f6e\uff0c\u522b\u6389\u5751\u91cc\u53bb\u4e86\uff01<\/p>\n<pre class=\"lang:default decode:true \">chcon -Rt mysqld_db_t \/mnt\/sdb\/mysql\r\nchcon -Ru system_u \/mnt\/sdb\/mysql\r\nchown -R mysql:mysql \/mnt\/sdb\/mysql<\/pre>\n<p>\u91cd\u65b0\u542f\u52a8mariadb\uff0c\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u63d0\u793a\u672a\u627e\u5230socket\uff1a<br \/>\n\u201cERROR 2002 (HY000): Can\u2019t connect to local MySQL server through socket \u2018\/var\/lib\/mysql\/mysql.sock\u2019 (2)\u201d<br \/>\n\u660e\u660e\u914d\u7f6e\u4e0a\u5df2\u7ecf\u4fee\u6539\u4e86\uff0c\u4f46\u542f\u52a8\u5374\u627e\u4e0d\u5230\u76f8\u5e94\u7684socket\uff0c\u6211\u4e0d\u7981\u9677\u5165\u4e86\u601d\u7d22\u3002\u867d\u7136\u4e3b\u914d\u7f6e\u6539\u4e86socket\uff0c\u90a3\u4e48\u4f1a\u4e0d\u4f1a\u662f\u76f8\u5e94\u7684client\u6ca1\u6709\u76d1\u542c\u5230socket\u3002cd\u5230\/mnt\/sdb\/mysql\uff0c\u8fd0\u884cmysql -uroot -p &#8211;socket=mysql.sock\uff0c\u53d1\u73b0\u53ef\u4ee5\u8fde\u63a5\u4e86\uff01\u7f16\u8f91\uff1a<br \/>\nvim \/etc\/my.cnf.d\/client.cnf\u5728[client]\u4e0b\u9762\u6dfb\u52a0socket=\/mnt\/sdb\/mysql\/mysql.sock\uff08\u5982\u679c\u539f\u6765\u7684\u76ee\u5f55\u8fd8\u4fdd\u7559\u7740\uff0c\u4e5f\u53ef\u4ee5\u7528\u8fd9\u6761\u547d\u4ee4\u89e3\u51b3\u95ee\u9898ln -s \/mnt\/sdb\/mysql\/mysql.sock \/var\/lib\/mysql\/mysql.sock\uff09<br \/>\n\u518d\u6b21\u901a\u8fc7\u547d\u4ee4\u884c\u8fde\u63a5mysql -uroot -p\uff0c\u4e0d\u7528\u6307\u5b9asocket\u4e5f\u53ef\u4ee5\u8fde\u63a5\u4e86\u3002<\/p>\n<p>\u6253\u5f00\u7f51\u7ad9\uff0c\u53d1\u73b0\u8fd8\u662f\u65e0\u6cd5\u8fde\u63a5\u6570\u636e\u5e93\uff0c\u8fd9\u91cc\u5e94\u8be5\u662fphp\u91cc\u9762\u6ca1\u6709\u6307\u5b9asocket\u5bfc\u81f4\u7684\uff0c\u7f16\u8f91\uff1avim \/etc\/php.ini\uff0c\u6307\u5b9a\u76f8\u5e94\u7684socket<br \/>\nmysql.default_socket = \/mnt\/sdb\/mysql\/mysql.sock<br \/>\nmysqli.default_socket = \/mnt\/sdb\/mysql\/mysql.sock<br \/>\n\u8fd9\u65f6\uff0c\u5e94\u8be5\u5c31\u80fd\u6253\u5f00\u7f51\u7ad9\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u6bb5\u65f6\u95f4\uff0c\u53bb\u4e2d\u7f51\u79d1\u6280\u5f00\u901a\u4e86\u4e00\u4e2a\u4e91\u670d\u52a1\u5668\uff0clinux\u7cfb\u7edf\uff0c\u5b89\u88c5\u4e86LEMP\u73af\u5883\uff08\u6570\u636e<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":2,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":33,"href":"https:\/\/yyshell.com\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions\/33"}],"wp:attachment":[{"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yyshell.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}