1.首先下载mysql的源码包
wgethttp://down1.chinaunix.net/distfiles/mysql-5.5.20.tar.gz
2.安装需要的编译工具
yum install cmake make ncurses-devel ncurses gcc gcc-c++ -y
3.解压源码包
tar -zxvf mysql-5.5.20.tar.gzcd mysql-5.5.20
4.开始编译安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56/-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DMYSQL_DATADIR=/data/mysql/-DSYSCOnFDIR=/etc-DMYSQL_USER=mysql-DMYSQL_TCP_PORT=3306-DWITH_XTRADB_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_PARTITION_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DWITH_EXTRA_CHARSETS=1-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DEXTRA_CHARSETS=all-DWITH_BIG_TABLES=1-DWITH_DEBUG=0`
makemake install
5.设置开机启动和配置文件
cd /usr/local/mysql56/cp support-files/my-large.cnf/ etc/my.cnfcp support-files/mysql.server /etc/init.d/mysqldchkconfig –add mysqldchkconfig –level 35 mysqld onmkdir -p /data/mysqluseradd mysql
6.初始化
/etc/init.d/mysqld/usr/local/mysql56/scripts/mysql_install_db –user=mysql –datadir=/data/mysql/ –basedir=/usr/local/mysql56/ln -s /usr/local/mysql55/bin/* /usr/bin/