分类: Mysql/postgreSQL
2012-08-29 16:25:27
mysql 5.5.16下载页面:
安装好cmake,mysql 5.5.x貌似都要用cmake来编译mysql了。
解压下载下来到源码包,查看INSTALL-SOURCE
# Preconfiguration setup
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# Beginning of source-build specific instructions
shell> tar zxvf mysql-VERSION.tar.gz
shell> cd mysql-VERSION
shell> cmake .
shell> make
shell> make install
# End of source-build specific instructions
# Postinstallation setup
shell> cd /usr/local/mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
# Next command is optional
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
注意上面的VERSION指的是你下载的mysql的版本号。 我安装的过程中遇到了一个ERROR:
CMake Error at cmake/readline.cmake:83 (MESSAGE):这是因为系统中缺少 libncurses5-dev, 安装之,然后rm CMakeCache.txt后再cmake .
接着又碰到一个问题, 大概如下:
CMake Error at /usr/share/cmake-2.8/Modules/CMakeCXXInformation.cmake:35 (GET_FILENAME_COMPONENT): get_filename_component called with incorrect number of arguments Call Stack (most recent call first): CMakeLists.txt:3 (PROJECT) ......Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
我又apt-get install g++后再来一次,很幸运,总算过了。
接下来到了 install_db时又报错了,说什么 FATAL ERROR: Could not find errmsg.sys 或者 mysqld,很奇怪,上网搜了说应该是/etc/my.cnf的问题,我找了一下没找到,倒是发现有个/etc/mysql/的目录,好像是我前几天装的,删掉该目录后就没报错了。
最后一步改成
shell> cp support-files/mysql.server /etc/init.d/mysqld
shell> chkconfig -add mysqld
在编译安装 MySQL 5.5.x 之前,需要最少安装的包有:bison,gcc、gcc-c++、cmake、ncurses-devel,安装这些依赖包后,把原来解压出来的mysql源码目录删除掉,再重新解压出来,再去编译.