# 安装依赖包[root@localhost ~]# yum -y install gcc gcc-c++ autoconf* automake* zlib* libxml* ncurses-devel ncurses libgcrypt* libtool* cmake openssl openssl-devel bison bison-devel unzip wget# 进入指定目录下载[root@localhost ~]# cd /usr/local/src[root@localhost ~]# wget http://cdn.mysql.com//downloads/mysql-5.6/mysql-5.6.27.tar.gz# 添加mysql运行账户[root@localhost ~]# /usr/sbin/groupadd mysql[root@localhost ~]# /usr/sbin/useradd mysql -g mysql -s /sbin/nologin -m# 解压下载源码包[root@localhost src]# tar zxvf mysql-5.6.27.tar.gz[root@localhost src]# cd mysql-5.6.27# 编译三步曲[root@localhost mysql-5.6.27]# cmake \-dcmake_install_prefix=/usr/local/mysql \-dmysql_datadir=/data/mysql \-dsysconfdir=/etc \-dwith_myisam_storage_engine=1 \-dwith_innobase_storage_engine=1 \-dwith_memory_storage_engine=1 \-dwith_readline=1 \-dmysql_unix_addr=/var/lib/mysql/mysql.sock \-dmysql_tcp_port=3306 \-denabled_local_infile=1 \-dwith_partition_storage_engine=1 \-dextra_charsets=all \-ddefault_charset=utf8 \-ddefault_collation=utf8_general_ci[root@localhost mysql-5.6.27]# make && make install# 复制mysql配置文件[root@localhost mysql-5.6.27]# cp -rf support-files/my-default.cnf /etc/my.cnf# 复制myssql启动管理文件[root@localhost mysql-5.6.27]# cp support-files/mysql.server /etc/init.d/mysqld# 赋权限[root@localhost ~]# chmod 755 /etc/init.d/mysqld# 添加开机启动[root@localhost ~]# chkconfig --level 345 mysqld on# 创建数据库存放目录[root@localhost ~]# mkdir -p /data/mysql# 给数据库目录权限赋给mysql用户[root@localhost ~]# chown -r mysql:mysql /usr/local/mysql[root@localhost ~]# chown -r mysql:mysql /data/mysql[root@localhost ~]# cd /usr/local/mysql[root@localhost ~]# ln -s /usr/local/mysql/bin/* /usr/sbin/# 数据库初始化[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --user=mysql --datadir=/data/mysql# 启动数据库[root@localhost ~]# /etc/init.d/mysqld start、# 对数据账户进行基本安全设置[root@localhost ~]# mysql_secure_installation