yum -y install cmake gcc-c++ ncurses-devel
useradd mysql -s /sbin/nologin
mkdir -p /var/mysql/data
chown -R mysql:mysql /var/mysql/data
mkdir /home/mysql
cd /home/mysql
wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39.tar.gz
tar -xvf mysql-5.6.39.tar.gz
mkdir /var/mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/var/mysql/sock/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DWITH_READLINE=1 \
-DWITH_SSL=yes \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
make && make install
#ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
#ln -s /usr/local/mysql/include/mysql /usr/include/mysql
#ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
rm -rf /etc/my.cnf
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#cp /usr/local/mysql/my-medium.cnf/my-default.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
cp /etc/my.cnf /etc/my.cnf.bak
cp /etc/rc.d/init.d/mysqld /etc/rc.d/init.d/mysqld.bak
#/etc/my.cnf *******************************************************
mkdir /var/mysql/sock
mkdir /var/mysql/pid
mkdir /var/mysql/error
touch /var/mysql/sock/mysql.sock
touch /var/mysql/pid/mysql.pid
touch /var/mysql/error/error.log
#client *******************************
sed -i '/^\[mysqld\]$/i\\[client\]' /etc/my.cnf
sed -i '/^\[client\]$/a\port \= 3306\n' /etc/my.cnf
sed -i '/^\[client\]$/a\socket \= \/var\/mysql\/sock\/mysql\.sock' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\skip\-external\-locking' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\key\_buffer\_size = 16M' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\max\_allowed\_packet \= 1M' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\table\_open\_cache \= 64' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\sort\_buffer\_size \= 512K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\net\_buffer\_length \= 8K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\read\_buffer\_size \= 256K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\read\_rnd\_buffer\_size \= 512K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\myisam\_sort\_buffer\_size \= 8M' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\port \= 3306' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\socket \= \/var\/mysql\/sock\/mysql\.sock' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\datadir\=\/var\/mysql\/data\/' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\log\-error\=\/var\/mysql\/error\/error\.log' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\pid\-file\=\/var\/mysql\/pid\/mysql\.pid' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\user\=mysql' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\tmpdir\=/tmp' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\basedir\=/usr/local/mysql' /etc/my.cnf
#/etc/init.d/mysqld *************************************
sed -i 's/^basedir\=$/basedir\=\/usr\/local\/mysql/g' /etc/init.d/mysqld
sed -i 's/^datadir\=$/datadir\=\/var\/mysql\/data/g' /etc/init.d/mysqld
sed -i '/^datadir\=\/var\/mysql\/data$/a\user\=mysql' /etc/init.d/mysqld
sed -i '/^datadir\=\/var\/mysql\/data$/a\tmpdir\=\/tmp' /etc/init.d/mysqld
#sed -i '/^datadir\=\/var\/mysql\/data$/a\log\-error\=\/var\/mysql\/error\/error.log' /etc/init.d/mysqld
#sed -i '/^datadir\=\/var\/mysql\/data$/a\datadir\=\/var\/mysql\/pid\/mysql.pid' /etc/init.d/mysqld
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/mysql/data \
--pid-file=/var/mysql/pid/mysql.pid --log-error=/var/mysql/error/error.log --tmpdir=/tmp
#/usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
#start *************************************************
chown -R mysql:mysql /etc/init.d/mysqld
chown -R mysql:mysql /etc/my.cnf
chown -R mysql:mysql /var/mysql
chkconfig --add mysqld
chkconfig mysqld on
chown -R mysql:mysql /usr/local/mysql
useradd mysql -s /sbin/nologin
mkdir -p /var/mysql/data
chown -R mysql:mysql /var/mysql/data
mkdir /home/mysql
cd /home/mysql
wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.39.tar.gz
tar -xvf mysql-5.6.39.tar.gz
mkdir /var/mysql
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/var/mysql/sock/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DWITH_READLINE=1 \
-DWITH_SSL=yes \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/var/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost
make && make install
#ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
#ln -s /usr/local/mysql/include/mysql /usr/include/mysql
#ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
rm -rf /etc/my.cnf
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
#cp /usr/local/mysql/my-medium.cnf/my-default.cnf /etc/my.cnf
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
cp /etc/my.cnf /etc/my.cnf.bak
cp /etc/rc.d/init.d/mysqld /etc/rc.d/init.d/mysqld.bak
#/etc/my.cnf *******************************************************
mkdir /var/mysql/sock
mkdir /var/mysql/pid
mkdir /var/mysql/error
touch /var/mysql/sock/mysql.sock
touch /var/mysql/pid/mysql.pid
touch /var/mysql/error/error.log
#client *******************************
sed -i '/^\[mysqld\]$/i\\[client\]' /etc/my.cnf
sed -i '/^\[client\]$/a\port \= 3306\n' /etc/my.cnf
sed -i '/^\[client\]$/a\socket \= \/var\/mysql\/sock\/mysql\.sock' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\skip\-external\-locking' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\key\_buffer\_size = 16M' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\max\_allowed\_packet \= 1M' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\table\_open\_cache \= 64' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\sort\_buffer\_size \= 512K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\net\_buffer\_length \= 8K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\read\_buffer\_size \= 256K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\read\_rnd\_buffer\_size \= 512K' /etc/my.cnf
#sed -i '/^\[mysqld\]$/a\myisam\_sort\_buffer\_size \= 8M' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\port \= 3306' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\socket \= \/var\/mysql\/sock\/mysql\.sock' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\datadir\=\/var\/mysql\/data\/' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\log\-error\=\/var\/mysql\/error\/error\.log' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\pid\-file\=\/var\/mysql\/pid\/mysql\.pid' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\user\=mysql' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\tmpdir\=/tmp' /etc/my.cnf
sed -i '/^\[mysqld\]$/a\basedir\=/usr/local/mysql' /etc/my.cnf
#/etc/init.d/mysqld *************************************
sed -i 's/^basedir\=$/basedir\=\/usr\/local\/mysql/g' /etc/init.d/mysqld
sed -i 's/^datadir\=$/datadir\=\/var\/mysql\/data/g' /etc/init.d/mysqld
sed -i '/^datadir\=\/var\/mysql\/data$/a\user\=mysql' /etc/init.d/mysqld
sed -i '/^datadir\=\/var\/mysql\/data$/a\tmpdir\=\/tmp' /etc/init.d/mysqld
#sed -i '/^datadir\=\/var\/mysql\/data$/a\log\-error\=\/var\/mysql\/error\/error.log' /etc/init.d/mysqld
#sed -i '/^datadir\=\/var\/mysql\/data$/a\datadir\=\/var\/mysql\/pid\/mysql.pid' /etc/init.d/mysqld
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/var/mysql/data \
--pid-file=/var/mysql/pid/mysql.pid --log-error=/var/mysql/error/error.log --tmpdir=/tmp
#/usr/local/mysql/bin/mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
#start *************************************************
chown -R mysql:mysql /etc/init.d/mysqld
chown -R mysql:mysql /etc/my.cnf
chown -R mysql:mysql /var/mysql
chkconfig --add mysqld
chkconfig mysqld on
chown -R mysql:mysql /usr/local/mysql