yum install cmake ncurses-devel gcc-c++ -y
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.41.tar.gz
tar xzvf mysql-5.5.41.tar.gz
cd mysql-5.5.41
useradd -M -s /sbin/nologin mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \
-DWITH_INNOBASE_STORAGE_ENGINE=ON \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_PARTITION_STORAGE_ENGINE=1
make $$ make install
#初始化数据库
cd /usr/local/mysql/bin
scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/
cd /usr/local/mysql
cp support-files/my-medium.cnf /etc/my.cnf 复制配置文件
cp support-files/mysql-server /etc/init.d/mysqld 复制到系统
chmod 755 /etc/init.d/mysqld 修改属性
chkconfig --add /etc/init.d/mysqld -------添加为服务
chkconfig mysqld --level 235 on 设置在235 级别是开机自动运行
#配置环境
#将mysql 的bin目录加到PATH中,在/etc/profile中加入myslq/bin
export PATH=/usr/local/mysql/bin:$PATH
原文地址:http://xiaowei8.blog.51cto.com/2323881/1618534