1. 下载最新的mysql5.6.src.rpm源代码包

  2. 解压源代码包

     rpm -i MySQL-5.6.20-1.rhel5.src.rpm

     cd /usr/src/redhat/SPECS

     rpmbuild -bp mysql.spec

在/usr/src/redhat/BUIlD下面就产生了源代码

3. 安装cmake

cd /usr/local/src

tar -zxvf cmake2.8.5.tar.gz

./configure

gmake && gmake install

yum install -y openssl openssl-devel


4.安装mysql

groupadd mysql

useradd -g mysql mysql

mkdir -p /data/mysql

chown -R mysql:mysql /data/mysql

tar -zxvf mysql5.6.20.tar.gz

cd mysql5.6.20


cmake . \

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/data/mysql \

-DSYSCONFDIR=/usr/local/mysql/etc   \

-DMYSQL_TCP_PORT=3306 \

-DENABLED_LOCAL_INFILE=1 \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8  \

-DDEFAULT_COLLATION=utf8_general_ci  \

-DMYSQL_USER=mysql \

-DWITH_DEBUG=0 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_SSL=system \

-DWITH_EMBEDDED_SERVER=1 \

-DWITH_READLINE=1 \

-DWITH_SSL=bundled  \

-DWITH_PARTITION_STORAGE_ENGINE=1


make && make install


5. 添加服务

cp support-files/mysql.server /etc/init.d/mysqld #复制脚本

chmod +x /etc/init.d/mysqld #增加可执行权限

chkconfig --add mysqld #增加至sysV服务

chkconfig mysqld on #开机自启动


6. 修改mysqld

vi /etc/init.d/mysqld

basedir=/usr/local/mysql

datadir=/data/mysql


7.修改配置文件my.cnf

datadir=/data/mysql


8.修改密码


bin/mysqladmin -u root password 'xxx'