{"id":2906,"date":"2016-09-28T13:25:36","date_gmt":"2016-09-28T05:25:36","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2906"},"modified":"2016-09-28T13:25:36","modified_gmt":"2016-09-28T05:25:36","slug":"mysql%e5%a4%9a%e5%ae%9e%e4%be%8b%e7%8e%af%e5%a2%83%e7%9a%84%e5%88%9b%e5%bb%bacentos","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2906.html","title":{"rendered":"MySQL\u591a\u5b9e\u4f8b\u73af\u5883\u7684\u521b\u5efa(CentOS)"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531\uff1a<\/h5>\n<p>\u8981\u505a\u4e00\u4e2a\u96c6\u5408\u591a\u79cd\u529f\u80fd\u7684\u7f51\u7ad9\uff0c\u4e0d\u540c\u7684\u529f\u80fd\u5bf9\u5e94\u7740\u4e0d\u540c\u7684MySQL\u6570\u636e\u5e93\uff0c\u4e14\u5206\u6563\u5728\u591a\u53f0\u670d\u52a1\u5668\u4e0a\u3002\u8003\u8651\u5230\u76f4\u63a5\u5728\u539f\u59cb\u6570\u636e\u5e93\u4e0a\u8fdb\u884c\u64cd\u4f5c\u4f1a\u5f71\u54cd\u6027\u80fd\u548c\u53ef\u7528\u6027\uff0c\u6240\u4ee5\u51b3\u5b9a\u521b\u5efaMySQL\u4e3b\u4ece\uff0c\u5c06\u6240\u6709\u7684\u4ece\u5e93\u653e\u5728\u4e00\u53f0\u670d\u52a1\u5668\u4e0a\uff0c\u597d\u5904\u662f\u96c6\u4e2d\u5b58\u653e\u6613\u4e8e\u7ba1\u7406\uff0c\u4e14\u4e0d\u4f1a\u5bf9\u539f\u59cb\u6570\u636e\u5e93\u9020\u6210\u8f83\u5927\u5f71\u54cd\u3002\u8fd9\u4e48\u505a\u9700\u8981\u5f00\u542f\u591a\u4e2aMySQL\u5b9e\u4f8b\uff0c\u4e00\u4e2a\u5b9e\u4f8b\u5bf9\u5e94\u4e00\u4e2a\u7279\u5b9a\u7684\u4ece\u5e93\u3002\u4e0b\u9762\u662f\u5728CentOS 6.x\u73af\u5883\u4e0b\u521b\u5efa\u591a\u4e2aMySQL\u5b9e\u4f8b\u7684\u6b65\u9aa4\uff0c\u5728\u6b64\u8bb0\u5f55\u603b\u7ed3\u4e00\u4e0b\uff0c\u65b9\u4fbf\u4ee5\u540e\u53c2\u8003\u3002<\/p>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<h6>1. \u521b\u5efa\u4e00\u4e2a\u65b0\u7684MySQL\u6570\u636e\u76ee\u5f55 <code>\/opt\/mysql_3307<\/code> (\u8981\u8bb0\u5f97\u5c06\u76ee\u5f55\u7684\u7528\u6237\u548c\u7ec4\u6539\u6210mysql)<\/h6>\n<pre class=\"lang:default decode:true \"># mkdir -p \/opt\/mysql_3307\n# chown mysql.mysql \/opt\/mysql_3307\/<\/pre>\n<h6>2. \u5229\u7528\u5df2\u6709\u7684MySQL\u914d\u7f6e\u6587\u4ef6(\/etc\/my.cnf)\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u540d\u4e3a my.cnf.3307 \u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5e76\u66f4\u65b0\u5176\u4e2d\u7684 datadir\/port \u914d\u7f6e\uff1a<\/h6>\n<pre class=\"lang:default decode:true\"># cp \/etc\/my.cnf \/etc\/my.cnf.3307\n# vi \/etc\/my.cnf.3307\n    datadir=\/opt\/mysql_3307\n    port=3307<\/pre>\n<h6>3. \u5229\u7528\u5df2\u6709\u7684MySQL\u542f\u52a8\u811a\u672c(\/etc\/init.d\/mysql)\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u540d\u4e3a mysql3307 \u7684\u542f\u52a8\u811a\u672c\u7528\u4e8e \u542f\u52a8\/\u505c\u6b62\/\u91cd\u8f7d \u65b0\u7684MySQL\u5b9e\u4f8b\uff1a<\/h6>\n<pre class=\"lang:default decode:true\"># cp \/etc\/init.d\/mysql \/etc\/init.d\/mysql3307<\/pre>\n<h6>4. \u5bf9\u521a\u624d\u65b0\u5efa\u7684\u540d\u4e3a mysql3307 \u7684\u542f\u52a8\u811a\u672c\u505a\u4e00\u4e9b\u4fee\u6539(\u81f3\u5c11\u9700\u89814\u5904\u4fee\u6539)\uff1a<\/h6>\n<pre class=\"lang:default decode:true\"># vi \/etc\/init.d\/mysql3307\n\n\u4fee\u65391: \u5c06\u4e0b\u9762\u4e00\u884c\u7684\u5185\u5bb9\u6dfb\u52a0\u5230 \u7b2c138\u884c(\u5373 --pid-file= \u6240\u5728\u884c) \u4e4b\u540e\u7528\u6765\u5904\u7406\u7aef\u53e3\u9009\u9879\n\n--port=*) port=`echo \"$arg\" | sed -e 's\/^[^=]*=\/\/'` ;;\n\n\u4fee\u65392: \u4fee\u6539 \u7b2c215\u884c(\u5373 conf=\/etc\/my.cnf \u6240\u5728\u884c) \u66f4\u65b0\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\uff1a\n\nconf=\/etc\/my.cnf.3307\n\n\u4fee\u65393: \u4fee\u6539 \u7b2c257\u884c(\u5373 parse_server_arguments `$print_defaults \u6240\u5728\u884c) \u6dfb\u52a0\u300c-c\u300d\u9009\u9879\uff0c\u4f7f\u5176\u5728\u89e3\u6790\u53c2\u6570\u65f6\u4f1a\u53bb\u8bfb\u53d6\u521a\u624d\u65b0\u5efa\u7684\u914d\u7f6e\u6587\u4ef6\uff1a\n\nparse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server -c\/etc\/my.cnf.3307`\n\n\u4fee\u65394: \u4fee\u6539 \u7b2c284\u884c(\u5373 \u300cwait_for_pid created\u300d \u4e0a\u4e00\u884c) \u6dfb\u52a0\u300c--defaults-file=\/etc\/my.cnf.3307 --port=\"$port\"\u300d\u9009\u9879\uff0c\u8bbe\u7f6e\u9ed8\u8ba4\u7684\u914d\u7f6e\u6587\u4ef6\u548c\u7aef\u53e3\uff1a\n\n$bindir\/mysqld_safe --defaults-file=\/etc\/my.cnf.3307 --port=\"$port\" --datadir=\"$datadir\" --pid-file=\"$mysqld_pid_file_path\" --socket=\"$datadir\"\/mysql3307.sock $other_args &gt;\/dev\/null 2&gt;&amp;1 &amp;<\/pre>\n<h6>5. \u4e3a\u65b0\u7684MySQL\u5b9e\u4f8b\u5b89\u88c5\u9ed8\u8ba4\u7684\u8868\uff1a<\/h6>\n<pre class=\"lang:default decode:true\"># mysql_install_db --datadir=\/opt\/mysql_3307 --defaults-file=\/etc\/my.cnf.3307 --user=mysql<\/pre>\n<h6>6. \u542f\u52a8\u65b0\u7684MySQL\u5b9e\u4f8b\uff1a<\/h6>\n<pre class=\"lang:default decode:true\"># \/etc\/init.d\/mysql3307 start<\/pre>\n<h6>7. \u4e3a\u8be5MySQL\u5b9e\u4f8b\u8bbe\u7f6e\u5bc6\u7801\uff0c\u5e76\u8fde\u63a5\u5230\u8be5\u5b9e\u4f8b\uff1a<\/h6>\n<pre class=\"lang:default decode:true\"># \/usr\/bin\/mysqladmin -u root -h127.0.0.1 -P3307 password 'new_password'\n# mysql -uroot -h127.0.0.1 -P3307 -p<\/pre>\n<h6>8. \u5c06\u8be5\u670d\u52a1\u6dfb\u52a0\u5230\u542f\u52a8\u5217\u8868\u4e2d[\u53ef\u9009]<\/h6>\n<pre class=\"lang:default decode:true\"># chkconfig --add mysql3307\n# chkconfig mysql3307 --level 2345 on<\/pre>\n<p>\u5982\u679c\u4f60\u60f3\u90e8\u7f72\u66f4\u591a\u7684MySQL\u5b9e\u4f8b\uff0c\u7167\u7740\u4e0a\u9762\u7684\u65b9\u6cd5\u4e00\u6b65\u4e00\u6b65\u6765\u5373\u53ef(\u6ce8\u610f\u8fdb\u884c\u4e00\u4e9b\u4fee\u6539)\uff0c\u4e0d\u8fc7\u8981\u786e\u4fdd\u6709\u8db3\u591f\u7684\u5185\u5b58\u548cCPU\u8d44\u6e90\u3002<\/p>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<p>https:\/\/opensourcedbms.com\/dbms\/running-multiple-mysql-5-6-instances-on-one-server-in-centos-6rhel-6fedora\/<\/p>\n<ul>\n<li><a href=\"http:\/\/sharadchhetri.com\/2013\/12\/02\/create-multiple-mysql-instance-centos-6-4-red-hat-6-4\/\">http:\/\/sharadchhetri.com\/2013\/12\/02\/create-multiple-mysql-instance-centos-6-4-red-hat-6-4\/<\/a><\/li>\n<li><a href=\"https:\/\/www.percona.com\/blog\/2014\/08\/26\/mysqld_multi-how-to-run-multiple-instances-of-mysql\/\">https:\/\/www.percona.com\/blog\/2014\/08\/26\/mysqld_multi-how-to-run-multiple-instances-of-mysql\/<\/a> #\u901a\u8fc7mysqld_multi\u642d\u5efa\u591a\u4e2a\u5b9e\u4f8b<\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u8981\u505a\u4e00\u4e2a\u96c6\u5408\u591a\u79cd\u529f\u80fd\u7684\u7f51\u7ad9\uff0c\u4e0d\u540c\u7684\u529f\u80fd\u5bf9\u5e94\u7740\u4e0d\u540c\u7684MySQL\u6570\u636e\u5e93\uff0c\u4e14\u5206\u6563\u5728\u591a\u53f0\u670d\u52a1\u5668 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,23,11],"tags":[16],"class_list":["post-2906","post","type-post","status-publish","format-standard","hentry","category-database","category-knowledgebase-2","category-linux","tag-mysql"],"views":3203,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2906","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2906"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2906\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2906"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}