{"id":2940,"date":"2011-06-22T00:32:00","date_gmt":"2011-06-21T16:32:00","guid":{"rendered":"http:\/\/www.orczhou.com\/?p=2940"},"modified":"2011-11-25T17:09:16","modified_gmt":"2011-11-25T09:09:16","slug":"compile-and-install-mysql-5-5-from-source","status":"publish","type":"post","link":"https:\/\/www.orczhou.com\/index.php\/2011\/06\/compile-and-install-mysql-5-5-from-source\/","title":{"rendered":"Linux\u4e0bMySQL 5.5\u7f16\u8bd1\u5b89\u88c5"},"content":{"rendered":"<p>\u4e4b\u524d\u5199\u8fc7\u4e00\u7bc7Linux\u4e0b<a href=\"http:\/\/www.orczhou.com\/index.php\/2010\/06\/compile-mysql-from-source\/\">\u7f16\u8bd1\u5b89\u88c5MySQL<\/a>\uff0c\u4f46\u662f\u57285.5\u7248\u672c\u4e4b\u540eMySQL\u81ea\u52a8\u5316\u5efa\u6784\u5de5\u5177\u4ece<a href=\"http:\/\/www.gnu.org\/s\/hello\/manual\/automake\/Autotools-Introduction.html\">GUN Autotools<\/a>\u6362\u6210\u4e86\u8de8\u5e73\u53f0\u7684<a href=\"http:\/\/www.cmake.org\/\">Cmake<\/a>\u7cfb\u7edf\uff0c\u7f16\u8bd1\u548c\u914d\u7f6e\u548c\u539f\u6765\u6709\u4e9b\u4e0d\u540c\uff0c\u8fd9\u91cc\u505a\u4e00\u4e2a\u7b80\u5355\u7684\u5c0f\u7ed3\u3002<\/p>\n<div class=\"myt1\">1. \u5b89\u88c5CMake<\/div>\n<p>Cmake\u662f\u8de8\u5e73\u53f0\u7684\u5de5\u5177\uff0c\u5982\u679c\u4e4b\u524d\u5c31\u5c1d\u8bd5\u8fc7\u5728<a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.1\/en\/windows-source-build.html\">Windows\u4e0a\u7f16\u8bd1MySQL<\/a>\u7684\u540c\u5b66\uff0c\u5c31\u5e94\u8be5\u8fd8\u8bb0\u5f97CMake\u3002<\/p>\n<p>\u6211\u7684\u73af\u5883\u662f\u4e0d\u81ea\u5e26CMake\uff08\u73af\u5883\uff1aRHEL5.4\uff0cYUM\u4ed3\u5e93\u91cc\u9762\u6ca1\u6709CMake\uff09\uff0c\u6240\u4ee5\u9700\u8981\u81ea\u5df1\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u7b80\u5355\u3001\u987a\u5229\uff0c\u6ca1\u6709\u9047\u5230\u4efb\u4f55\u4f9d\u8d56\u95ee\u9898&#8230;&#8230;:)<\/p>\n<div class=\"mycode\">$tar zxf cmake-2.6.4.tar.gz<br \/>\n$cd cmake-2.6.4<br \/>\n$.\/bootstrap<br \/>\n$make<br \/>\n$sudo make install\n<\/div>\n<p>CMake<a href=\"http:\/\/www.cmake.org\/cmake\/resources\/software.html\">\u4e0b\u8f7d<\/a>\u3001<a href=\"http:\/\/www.cmake.org\/cmake\/help\/install.html\">\u5b89\u88c5\u53c2\u8003<\/a>\u3002<\/p>\n<div class=\"myt1\">2. CMake\u7f16\u8bd1MySQL 5.5<\/div>\n<div class=\"mycode\">tar zxf mysql-5.5.11.tar.g<br \/>\ncd mysql-5.5.11<br \/>\nCFLAGS=&#8221;-O3&#8243; CXX=gcc<br \/>\nCXXFLAGS=&#8221;-O3 -felide-constructors -fno-exceptions -fno-rtti&#8221;<br \/>\ncmake . -LH|more        \/\/CMake\u4e0b\u67e5\u770bMySQL\u7684\u7f16\u8bd1\u914d\u7f6e<br \/>\ncmake . -DCMAKE_INSTALL_PREFIX=\/home\/mysql\/mysql -DEXTRA_CHARSETS=all<br \/>\nmake -j 8        \/\/8\u6838\u5e76\u884c\u7f16\u8bd1<br \/>\nmake install\n<\/div>\n<p>\u5176\u4e2d&#8221;ccmake . -D&#8230;&#8230;&#8221;\u4e5f\u53ef\u76f4\u63a5\u4f7f\u7528&#8221;cmake .&#8221;\uff0c\u8fd9\u6837\u4f1a\u8fdb\u5165\u4e00\u4e2a\u7b80\u5355\u6587\u672cGUI\u754c\u9762\u8fdb\u884cMySQL\u7f16\u8bd1\u53c2\u6570\u914d\u7f6e\uff1b<\/p>\n<p>\u53e6\u5916\uff0c\u539f\u6765\u7684AutoTools\u548c\u73b0\u5728CMake\u914d\u7f6e\u53c2\u6570\u7684\u53d8\u5316\uff0c\u5728MySQL Forge\u7684<a href=\"http:\/\/forge.mysql.com\/wiki\/Autotools_to_CMake_Transition_Guide\">Autotools to CMake Transition Guide<\/a>\u4e2d\u53ef\u4ee5\u67e5\u9605\u8be6\u7ec6\u7684\u5bf9\u6bd4\u8bf4\u660e\u3002<br \/>\n<!--more--><\/p>\n<div class=\"myt1\">3. \u7f16\u8bd1\u5b89\u88c5Step by Step<\/div>\n<p>\u9664\u4e86\u4e0a\u9762\u7f16\u8bd1\u90e8\u5206\u4e0d\u540c\u4e4b\u5916\uff0c\u5176\u4ed6\u7684\u8fc7\u7a0b\u548c\u539f\u6765\u7684\u7248\u672c\u90fd\u8fd8\u662f\u4e0d\u53d8\u7684\uff1a<\/p>\n<pre><div class=\"mycode\"># # # \u65b0\u5efa\u8fd0\u884cMySQL\u7684\u7528\u6237\r\ngroupadd dba\r\nuseradd -g dba mysql\r\ncp mysql-5.5.11.tar.gz \/home\/mysql\/\r\nchown -R mysql:dba \/home\/mysql\/mysql-5.5.11.tar.gz\r\n\r\n# # # \u5f00\u59cb\u7f16\u8bd1\u3001\u5b89\u88c5\r\nsu - mysql\r\ntar zxf mysql-5.5.11.tar.gz\r\ncd mysql-5.5.11\r\nCFLAGS=\"-O3\" CXX=gcc \r\nCXXFLAGS=\"-O3 -felide-constructors -fno-exceptions -fno-rtti\"\r\ncmake . -LH|more        \/\/CMake\u4e0b\u67e5\u770bMySQL\u7684\u7f16\u8bd1\u914d\u7f6e\r\ncmake . -DCMAKE_INSTALL_PREFIX=\/home\/mysql\/mysql -DEXTRA_CHARSETS=all\r\nmake -j 8 && make install   #-j \u8868\u793a\u5e0c\u671b\u4f7f\u7528cpu\u6838\u6570\r\n\r\n# # # \u5efa\u7acb\u914d\u7f6e\u6587\u4ef6\r\ncd \/home\/mysql\/mysql\r\nsu - root\r\ncp mysql\/share\/mysql\/my-medium.cnf \/etc\/my.cnf\r\nchown -R mysql:dba \/etc\/my.cnf\r\n\r\n# # # \u4fee\u6539\u914d\u7f6e\u6587\u4ef6 \u914d\u7f6e\u6570\u636e\u6587\u4ef6\u3001\u65e5\u5fd7\u7684\u8def\u5f84\r\nsu - mysql\r\nvi \/etc\/my.cnf\r\nbasedir = \/home\/mysql\/mysql\r\ndatadir = \/home\/mysql\/mysql\/data\r\nsocket = \/home\/mysql\/mysql\/run\/mysql.sock\r\nlog-error = \/home\/mysql\/mysql\/log\/alert.log\r\nlog_slow_queries = \/home\/mysql\/mysql\/log\/slow.log\r\n\r\nmkdir log run tmp\r\n\r\n# # # \u521d\u59cbMySQL\u914d\u7f6e\u8868\uff08\u7528\u6237\u8868 \u6743\u9650\u8868\u7b49\uff09\r\n.\/scripts\/mysql_install_db --basedir=\/home\/mysql\/mysql  --datadir=\/home\/mysql\/mysql\/data --user=mysql --force\r\n\r\n# # # \u542f\u52a8MySQL\r\n.\/bin\/mysqld_safe &<\/div><\/pre>\n<p>\u53c2\u8003\uff1a<\/p>\n<p>1. <a href=\"http:\/\/forge.mysql.com\/wiki\/CMake\">MySQL Forge::CMake<\/a><\/p>\n<p>2. <a href=\"http:\/\/forge.mysql.com\/wiki\/Autotools_to_CMake_Transition_Guide\">Autotools to CMake Transition Guide<\/a><\/p>\n<p>3. <a href=\"http:\/\/www.orczhou.com\/index.php\/2010\/06\/compile-mysql-from-source\/\">\u7f16\u8bd1\u5b89\u88c5MySQL<\/a><\/p>\n<p>4. <a href=\"http:\/\/dev.mysql.com\/doc\/refman\/5.5\/en\/source-configuration-options.html\">MySQL Source-Configuration Options<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u5199\u8fc7\u4e00\u7bc7Linux\u4e0b\u7f16\u8bd1\u5b89\u88c5MySQL\uff0c\u4f46\u662f\u57285.5\u7248\u672c\u4e4b\u540eMySQL\u81ea\u52a8\u5316\u5efa\u6784\u5de5\u5177\u4eceGUN Autotools\u6362\u6210\u4e86\u8de8\u5e73\u53f0\u7684Cmake\u7cfb\u7edf\uff0c\u7f16\u8bd1\u548c\u914d\u7f6e\u548c\u539f\u6765\u6709\u4e9b\u4e0d\u540c\uff0c\u8fd9\u91cc\u505a\u4e00\u4e2a\u7b80\u5355\u7684\u5c0f\u7ed3\u3002 1. \u5b89\u88c5CMake Cmake\u662f\u8de8\u5e73\u53f0\u7684\u5de5\u5177\uff0c\u5982\u679c\u4e4b\u524d\u5c31\u5c1d\u8bd5\u8fc7\u5728Windows\u4e0a\u7f16\u8bd1MySQL\u7684\u540c\u5b66\uff0c\u5c31\u5e94\u8be5\u8fd8\u8bb0\u5f97CMake\u3002 \u6211\u7684\u73af\u5883\u662f\u4e0d\u81ea\u5e26CMake\uff08\u73af\u5883\uff1aRHEL5.4\uff0cYUM\u4ed3\u5e93\u91cc\u9762\u6ca1\u6709CMake\uff09\uff0c\u6240\u4ee5\u9700\u8981\u81ea\u5df1\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u7b80\u5355\u3001\u987a\u5229\uff0c\u6ca1\u6709\u9047\u5230\u4efb\u4f55\u4f9d\u8d56\u95ee\u9898&#8230;&#8230;:) $tar zxf cmake-2.6.4.tar.gz $cd cmake-2.6.4 $.\/bootstrap $make $sudo make install CMake\u4e0b\u8f7d\u3001\u5b89\u88c5\u53c2\u8003\u3002 2. CMake\u7f16\u8bd1MySQL 5.5 tar zxf mysql-5.5.11.tar.g cd mysql-5.5.11 CFLAGS=&#8221;-O3&#8243; CXX=gcc CXXFLAGS=&#8221;-O3 -felide-constructors -fno-exceptions -fno-rtti&#8221; cmake . -LH|more \/\/CMake\u4e0b\u67e5\u770bMySQL\u7684\u7f16\u8bd1\u914d\u7f6e cmake . -DCMAKE_INSTALL_PREFIX=\/home\/mysql\/mysql -DEXTRA_CHARSETS=all make -j 8 \/\/8\u6838\u5e76\u884c\u7f16\u8bd1 make install \u5176\u4e2d&#8221;ccmake . -D&#8230;&#8230;&#8221;\u4e5f\u53ef\u76f4\u63a5\u4f7f\u7528&#8221;cmake .&#8221;\uff0c\u8fd9\u6837\u4f1a\u8fdb\u5165\u4e00\u4e2a\u7b80\u5355\u6587\u672cGUI\u754c\u9762\u8fdb\u884cMySQL\u7f16\u8bd1\u53c2\u6570\u914d\u7f6e\uff1b \u53e6\u5916\uff0c\u539f\u6765\u7684AutoTools\u548c\u73b0\u5728CMake\u914d\u7f6e\u53c2\u6570\u7684\u53d8\u5316\uff0c\u5728MySQL Forge\u7684Autotools to CMake Transition Guide\u4e2d\u53ef\u4ee5\u67e5\u9605\u8be6\u7ec6\u7684\u5bf9\u6bd4\u8bf4\u660e\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_eb_attr":"","inline_featured_image":false,"_tocer_settings":[],"footnotes":""},"categories":[6],"tags":[69,68,70],"class_list":["post-2940","post","type-post","status-publish","format-standard","hentry","category-mysql","tag-mysql5-5","tag-semi-sync","tag-semi-sync-replication"],"_links":{"self":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/comments?post=2940"}],"version-history":[{"count":13,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2940\/revisions"}],"predecessor-version":[{"id":3300,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/posts\/2940\/revisions\/3300"}],"wp:attachment":[{"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/media?parent=2940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/categories?post=2940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.orczhou.com\/index.php\/wp-json\/wp\/v2\/tags?post=2940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}