Linux centos6.3下编译安装MySQL具体步骤如下:
1. 下载Mysql安装文件,服务器安装版本为mysql-5.5.28。下载地址:http://dev.mysql.com/downloads/mirror.php?id=409825
2. 解压缩tar文件至当前目录mysql-5.5.28:tar -zxvf mysql-5.5.28.tar.gz
3. 安装编译工具及依赖库:yum -y install gcc gcc-c++ cmake bison
4. 添加Mysql用户:
/usr/sbin/groupadd mysqluseradd -g mysql mysql -s /usr/sbin/nologin
5. 建立安装及数据存储目录:
mkdir /usr/local/mysql
mkdir /usr/local/mysql/data
6. 编译安装:
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/usr/local/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make && make install安装完成。
需要注意的是在编译过程中可能会出现如下错误:
CMake Error at cmake/readline.cmake:82 (MESSAGE):Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on RedHat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:126 (FIND_CURSES)
cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:256 (MYSQL_CHECK_READLINE)
– Configuring incomplete, errors occurred!
错误原因:这是由于缺少ncurses-devel开发包导致的。解决方法:
1. 安装ncurses-devel开发包: yum install ncurses-devel*2. 删除编译cache文件:rm –f CMakeCache.txt
重新编译安装即可。