安装mysql

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   









评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值