MySQL-5.7.20

Last edited by Junyangz AT 2018-05-18 19:40:27

准备安装包

boost_1_59_0.tar.gz cmake-2.8.12.tar.gz mysql-5.7.20.tar.gz

安装编译环境

yum install -y gcc gcc-c++ ncurses-devel perl

添加MySQL用户及用户组

groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql5.7

编译安装

tar zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 /usr/local/boost
#cmake --version
tar zxvf cmake-2.8.12.tar.gz
cd cmake-2.8.12
./bootstrap
make && make install
cmake --version
cd ../
mkdir -p /usr/local/mysql-5.7.20
tar zxvf mysql-5.7.20.tar.gz
cd mysql-5.7.20
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.20 -DWITH_BOOST=/usr/local/boost/
make && make install
#unlink /usr/local/mysql
ln -s /usr/local/mysql-5.7 /usr/local/mysql
chown -R mysql:mysql /usr/local/mysql /usr/local/mysql-5.7
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

添加环境变量

vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
source /etc/profile
#echo $MYSQL_HOME
mysql -V

配置启动

配置MySQL

#/etc/my.cnf
[mysql]
default-character-set = utf8
socket=/data2/mysql5.7/run/mysql.sock
[mysqld]
basedir=/usr/local/mysql
datadir=/data1/mysql5.7
user=mysql
symbolic-links=0
lower-case-table_names=1
socket=/data2/mysql5.7/run/mysql.sock
log-error=/data2/mysql5.7/log/mysqld.log
pid-file=/data2/mysql5.7/log/mysqld.pid
max-allowed-packet=32M
open-files-limit=65535
server-id = 20
log-bin = /data2/mysql5.7/log/mysql-bin
auto-increment-increment = 2
auto-increment-offset = 2
log-slave-updates = 1
relay-log = /data2/mysql5.7/log/relay-bin
relay-log-purge = 1
read_only=0

开机自启&初始化及启动

chkconfig mysqld on
chkconfig mysqld --list
service mysql start
mysqld --initialize-insecure --user=mysql --datadir={$datadir}
# service mysql restart

Reference