1. 程式人生 > >47、CentOS7原始碼安裝mysql-5.7.24

47、CentOS7原始碼安裝mysql-5.7.24

find / -name mariadb*

yum -y remove mariadb-libs-5.5.44

find / -name mariadb*


yum -y groupinstall "Development tools" "Server Platform Development"

yum -y install https://mirrors.aliyun.com/epel/7Server/x86_64/Packages/e/epel-release-7-11.noarch.rpm

yum -y install cmake3

yum -y install readline-devel zlib-devel openssl-devel


mkdir -p /usr/local/boost

cd /usr/local/boost

wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

tar -xvzf boost_1_59_0.tar.gz

cd /root

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.24.tar.gz --no-check-certificate

tar xf mysql-5.7.24.tar.gz

cd mysql-5.7.24

cmake3 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=/usr/local/boost

make&&make install


useradd -r -s /sbin/nologin mysql

mkdir -p /mydata/data

mkdir -p /mydata/binlog

chown mysql:mysql /mydata/data

chown mysql:mysql /mydata/binlog

chown :mysql /usr/local/mysql -R

cd /usr/local/mysql/

cp support-files/mysql.server /etc/rc.d/init.d/mysqld

chmod +x /etc/rc.d/init.d/mysqld


vim /etc/my.cnf 

[mysqld]

basedir=/usr/local/mysql

datadir=/mydata/data

log-bin=/mydata/binlog/log-bin

server-id=1

chown mysql:mysql /etc/my.cnf


/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata/data

systemctl start mysqld


vim /etc/profile.d/mysql.sh

export PATH=/usr/local/mysql/bin:$PATH

source /etc/profile.d/mysql.sh