{"id":1245,"date":"2016-09-19T02:58:56","date_gmt":"2016-09-18T18:58:56","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=1245"},"modified":"2016-09-19T03:03:55","modified_gmt":"2016-09-18T19:03:55","slug":"centos7%e4%b8%8b%e5%ae%89%e8%a3%85mysql-5-6%e4%bf%ae%e6%94%b9%e5%ad%97%e7%ac%a6%e9%9b%86%e4%b8%bautf8%e5%b9%b6%e5%bc%80%e6%94%be%e7%ab%af%e5%8f%a3%e5%85%81%e8%ae%b8%e8%bf%9c%e7%a8%8b%e8%ae%bf%e9%97%ae","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/jishu\/shujuku\/centos7%e4%b8%8b%e5%ae%89%e8%a3%85mysql-5-6%e4%bf%ae%e6%94%b9%e5%ad%97%e7%ac%a6%e9%9b%86%e4%b8%bautf8%e5%b9%b6%e5%bc%80%e6%94%be%e7%ab%af%e5%8f%a3%e5%85%81%e8%ae%b8%e8%bf%9c%e7%a8%8b%e8%ae%bf%e9%97%ae\/","title":{"rendered":"CentOS7\u4e0b\u5b89\u88c5MySQL 5.6\u4fee\u6539\u5b57\u7b26\u96c6\u4e3autf8\u5e76\u5f00\u653e\u7aef\u53e3\u5141\u8bb8\u8fdc\u7a0b\u8bbf\u95ee"},"content":{"rendered":"<h3 id=\"\u524d\u8a00\">\u524d\u8a00<\/h3>\n<p>mysql\u6700\u521d\u7684\u514d\u8d39\u6218\u7565\u5df2\u7ecf\u6df1\u5165\u4eba\u5fc3\uff0c\u611f\u89c9\u81ea\u5df1\u4e00\u76f4\u90fd\u5728\u7528mysql\u3002\u4eca\u5929\u5728CentOS7\u4e0b\u88c5mysql\u3002\u53d1\u73b0\u539f\u6765centos\u4e0b\u9ed8\u8ba4\u6ca1\u6709mysql\uff0c\u56e0\u4e3a\u5f00\u59cb\u6536\u8d39\u4e86\uff0c\u53d6\u800c\u4ee3\u4e4b\u7684\u662f\u53e6\u4e00\u4e2amysql\u7684\u5206\u652f<code>mariadb<\/code>\uff0c\u8fd9\u4e2a\u662fmysql\u521b\u59cb\u4eba\u91cd\u65b0\u4e3b\u5bfc\u7684\u5206\u652f\u3002But, whatever, I want mysql. \u6240\u4ee5\uff0c\u8001\u8001\u5b9e\u5b9e\u7684\u5378\u8f7dmariadb\uff0c\u5b89\u88c5mysql\u3002<\/p>\n<h4 id=\"\u5378\u8f7dmariadb\">\u5378\u8f7dmariadb<\/h4>\n<pre><code class=\"hljs bash\"><span class=\"hljs-comment\">#\u5217\u51fa\u6240\u6709\u88ab\u5b89\u88c5\u7684rpm package <\/span>\r\nrpm -qa | grep mariadb\r\n\r\n<span class=\"hljs-comment\">#\u5378\u8f7d<\/span>\r\nrpm <span class=\"hljs-_\">-e<\/span> mariadb-libs-5.5.37-1.el7_0.x86_64\r\n\u9519\u8bef\uff1a\u4f9d\u8d56\u68c0\u6d4b\u5931\u8d25\uff1a\r\nlibmysqlclient.so.18()(64bit) \u88ab (\u5df2\u5b89\u88dd) postfix-2:2.10.1-6.el7.x86_64 \u9700\u8981\r\nlibmysqlclient.so.18(libmysqlclient_18)(64bit) \u88ab (\u5df2\u5b89\u88dd) postfix-2:2.10.1-6.el7.x86_64 \u9700\u8981\r\n\r\n<span class=\"hljs-comment\">#\u5f3a\u5236\u5378\u8f7d\uff0c\u56e0\u4e3a\u6ca1\u6709--nodeps<\/span>\r\nrpm <span class=\"hljs-_\">-e<\/span> --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64<\/code><\/pre>\n<h4 id=\"\u5b89\u88c5mariadb\">\u5b89\u88c5mariadb<\/h4>\n<p>centos\u4e0byum\u6682\u65f6\u6ca1\u6709mysql-server\u76f4\u63a5\u5b89\u88c5\u5305\uff1b<br \/>\nMariaDB\u662fMySQL\u793e\u533a\u5f00\u53d1\u7684\u5206\u652f\uff0c\u4e5f\u662f\u4e00\u4e2a\u589e\u5f3a\u578b\u7684\u66ff\u4ee3\u54c1.<\/p>\n<pre class=\"ssh\"><code class=\"hljs sql\">yum -y <span class=\"hljs-keyword\">install<\/span> mariadb-<span class=\"hljs-keyword\">server<\/span> mariadb mariadb-devel\r\nsystemctl <span class=\"hljs-keyword\">start<\/span> mariadb\r\nsystemctl <span class=\"hljs-keyword\">enable<\/span> mariadb\r\nmysql_secure_installation\r\nfirewall-cmd <span class=\"hljs-comment\">--permanent --add-service mysql<\/span>\r\nsystemctl restart firewalld.service\r\niptables -<span class=\"hljs-keyword\">L<\/span> -<span class=\"hljs-keyword\">n<\/span>|grep <span class=\"hljs-number\">3306<\/span><\/code><\/pre>\n<h4 id=\"\u5b89\u88c5mysql\">\u5b89\u88c5mysql<\/h4>\n<p>centos7\u4e2d\u9ed8\u8ba4\u6ca1\u6709mysql\u7684yum\u6e90\uff0c\u9700\u8981\u91cd\u65b0\u4e0b\u8f7d\uff1a<\/p>\n<h4 id=\"\u4e0b\u8f7dmysql\u7684repo\u6e90\">1.\u4e0b\u8f7dmysql\u7684repo\u6e90<\/h4>\n<pre><code class=\"hljs groovy\">$ wget <span class=\"hljs-string\">http:<\/span><span class=\"hljs-comment\">\/\/repo.mysql.com\/mysql-community-release-el7-5.noarch.rpm<\/span><\/code><\/pre>\n<h4 id=\"\u5b89\u88c5mysql-community-release-el7-5.noarch.rpm\u5305\">2.\u5b89\u88c5mysql-community-release-el7-5.noarch.rpm\u5305<\/h4>\n<pre><code class=\"hljs smalltalk\"><span class=\"hljs-string\">$ <\/span>sudo rpm -ivh mysql-community-release-el7<span class=\"hljs-number\">-5.<\/span>noarch.rpm<\/code><\/pre>\n<h4 id=\"\u5b89\u88c5mysql-1\">3.\u5b89\u88c5mysql<\/h4>\n<pre><code class=\"hljs sql\">$ sudo yum <span class=\"hljs-keyword\">install<\/span> mysql-<span class=\"hljs-keyword\">server<\/span><\/code><\/pre>\n<h4 id=\"\u91cd\u7f6e\u5bc6\u7801\">4.\u91cd\u7f6e\u5bc6\u7801<\/h4>\n<p>\u9700\u8981\u5148\u767b\u5f55\uff1a<\/p>\n<pre><code class=\"hljs smalltalk\"><span class=\"hljs-string\">$ <\/span>mysql -u root<\/code><\/pre>\n<p>\u6211\u4f7f\u7528\u7684root\uff0c\u4f46\u4e5f\u62a5\u9519\u4e86\uff1a<\/p>\n<blockquote><p>ERROR 2002 (HY000): Can\u2018t connect to local MySQL server through socket \u2018\/var\/lib\/mysql\/mysql.sock\u2018 (2)\uff0c\u539f\u56e0\u662f\/var\/lib\/mysql\u7684\u8bbf\u95ee\u6743\u9650\u95ee\u9898\u3002\u4e0b\u9762\u7684\u547d\u4ee4\u628a\/var\/lib\/mysql\u7684\u62e5\u6709\u8005\u6539\u4e3a\u5f53\u524d\u7528\u6237\uff1a<\/p><\/blockquote>\n<p><code>$ sudo chown -R openscanner:openscanner \/var\/lib\/mysql<\/code><\/p>\n<p>\u91cd\u542fmysql service:<\/p>\n<pre><code class=\"hljs smalltalk\"><span class=\"hljs-string\">$ <\/span>service mysqld restart<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\u8bbe\u7f6e\u5bc6\u7801\uff1a<\/p>\n<pre class=\"mysql\"><code class=\"hljs fortran\">$ mysql -u root\r\n\r\nmysql &gt; <span class=\"hljs-keyword\">use<\/span> mysql;\r\n\r\nmysql &gt; update user set password=password(\u2018<span class=\"hljs-number\">123456<\/span>\u2018) <span class=\"hljs-keyword\">where<\/span> user=\u2018root\u2018;\r\n\r\nmysql &gt; <span class=\"hljs-keyword\">exit<\/span>;<\/code><\/pre>\n<h4 id=\"\u5f00\u653e3306\u7aef\u53e3\">\u5f00\u653e3306\u7aef\u53e3<\/h4>\n<p>\u7531\u4e8ecentos7\u4f7f\u7528firewalld\u800c\u4e0d\u662fiptables,\u6240\u4ee5\uff1a<\/p>\n<pre><code class=\"hljs haskell\"><span class=\"hljs-meta\">#\u5f00\u653e3306<\/span>\r\n<span class=\"hljs-title\">firewall<\/span>-cmd <span class=\"hljs-comment\">--add-port=3306\/tcp <\/span>\r\n<span class=\"hljs-meta\">#\u67e5\u770b\u7aef\u53e3\u662f\u5426\u5f00\u653e<\/span>\r\n<span class=\"hljs-title\">firewall<\/span>-cmd <span class=\"hljs-comment\">--query-port=3306\/tcp<\/span><\/code><\/pre>\n<h4 id=\"\u5141\u8bb8mysql\u8fdc\u7a0b\u8bbf\u95ee\">\u5141\u8bb8mysql\u8fdc\u7a0b\u8bbf\u95ee<\/h4>\n<p>mysql\u9ed8\u8ba4\u662f\u4e0d\u5141\u8bb8\u8fdc\u7a0b\u8bbf\u95ee\u7684.<br \/>\nmysql -u root -p xxxx<\/p>\n<pre class=\"mysql\"><code class=\"hljs delphi\">mysql&gt;use mysql\r\nmysql&gt;grant all privileges <span class=\"hljs-keyword\">on<\/span> *.* <span class=\"hljs-keyword\">to<\/span> <span class=\"hljs-string\">'root'<\/span>@<span class=\"hljs-string\">'%'<\/span> identified by <span class=\"hljs-string\">'xxxxx(\u5bc6\u7801)'<\/span>;\r\nmysql&gt;flush privileges;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 mysql\u6700\u521d\u7684\u514d\u8d39\u6218\u7565\u5df2\u7ecf\u6df1\u5165\u4eba\u5fc3\uff0c\u611f\u89c9\u81ea\u5df1\u4e00\u76f4\u90fd\u5728\u7528mysql\u3002\u4eca\u5929\u5728CentOS7\u4e0b\u88c5mysql\u3002 &#8230; <a title=\"CentOS7\u4e0b\u5b89\u88c5MySQL 5.6\u4fee\u6539\u5b57\u7b26\u96c6\u4e3autf8\u5e76\u5f00\u653e\u7aef\u53e3\u5141\u8bb8\u8fdc\u7a0b\u8bbf\u95ee\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/jishu\/shujuku\/centos7%e4%b8%8b%e5%ae%89%e8%a3%85mysql-5-6%e4%bf%ae%e6%94%b9%e5%ad%97%e7%ac%a6%e9%9b%86%e4%b8%bautf8%e5%b9%b6%e5%bc%80%e6%94%be%e7%ab%af%e5%8f%a3%e5%85%81%e8%ae%b8%e8%bf%9c%e7%a8%8b%e8%ae%bf%e9%97%ae\/\" aria-label=\"\u9605\u8bfb CentOS7\u4e0b\u5b89\u88c5MySQL 5.6\u4fee\u6539\u5b57\u7b26\u96c6\u4e3autf8\u5e76\u5f00\u653e\u7aef\u53e3\u5141\u8bb8\u8fdc\u7a0b\u8bbf\u95ee\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[38,45],"class_list":["post-1245","post","type-post","status-publish","format-standard","hentry","category-shujuku","tag-linux","tag-mysql"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/1245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=1245"}],"version-history":[{"count":2,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/1245\/revisions"}],"predecessor-version":[{"id":1247,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/1245\/revisions\/1247"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=1245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=1245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=1245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}