MySql升级到5.5版本之后,源码编译配置工具换成了CMake,编译方式及加载的参数较之以前都有不小的变化,如果操作系统没有cmake命令,则需要首先编译安装cmake,这个工具安装比较简单,可以先到下列网址下载:http://www.cmake.org/cmake/resources/software.html,解压缩后make安装即可。
# cd cmake-2.8.12.1
# ./configure
# make
# make install
# 建mysql用户和组
shell> groupadd mysql
shell> useradd -r -g mysql mysql
# 解压tgz包,编译mysql
shell> tar zxvf mysql-5.5.34.src.tar.gz
shell> cd mysql-5.5.34
shell> cmake .
shell> make && make install
# 编译结束
# 更改用户和组属性,执行mysql_install_db初始化数据库
shell> cd /usr/local/mysql
shell> chown -R mysql:mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
#拷贝配置文件到/etc目录下,启动mysql
shell> cp support-files/my-medium.cnf /etc/my.cnf
shell> bin/mysqld_safe --user=mysql &
#设置mysql开机自启动
shell> cp support-files/mysql.server /etc/init.d/mysql.server
执行cmake报如下错误:是因为没有安装GCC
# cmake .
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error: your C compiler: "CMAKE_C_COMPILER-NOTFOUND" was not found. Please set CMAKE_C_COMPILER to a valid compiler path or name.
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
-- Configuring incomplete, errors occurred!
==================================================
解决方法:安装gcc和gcc-c++
yum install gcc
yum install gcc-c++
#删除cache文件,不删除还会报错
rm CMakeCache.txt
cmake .
2.编译快结束时,又报如下错误:
Warning: Bison executable not found in PATH
解决方法:安装bison
yum install bison
rm CMakeCache.txt
cmake .
#编译通过
make && make install
#执行时间比较长
3.无法启动mysql
bin/mysqld_safe --user=mysql & 无法启动
解决方法:
查看日志,发现在/var/run下没有mysqld文件夹,导致无法创建pid文件,创建mysql目录 加到mysql用户组
4.把mysql服务加入到系统中
# cd support-files/
# cp my-large.cnf /etc/my.cnf
# cp mysql.server /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
# chkconfig --level 234 mysqld off
# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:off 4:off 5:on 6:off
service mysqld start会报无权限
chmod a+wrx /etc/init.d/mysql
最后还需要把mysql home添加到path里