CentOS 7 Compiler and Installation of MySQL 5.7.24


Installation dependency

(1) cmake is a compilation tool for the new version of MySQL

sudo yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel 
sudo yum install zlib zlib-devel cmake ncurses ncurses-devel bison bison-devel
The following dependencies need to be installed in CentOS 7 and not in CentOS 6
sudo yum install perl perl-devel autoconf

Install boost

If you install versions of MySQL 5.7 or above, you need to install boost before compiling and installing, because high-level versions of MySQL require the installation of boots libraries to run properly. Otherwise, CMake Error at cmake/boost.cmake:81 error will be reported.

1. Switch to the / usr / local directory and download boost from it

MySQL 5.7.24 requires boost version 1.59, higher version does not apply MySQL 5.7.24
wget http://www.sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

2. Unzip and rename

tar zxvf boost_1_59_0.tar.gz
mv boost_1_59_0 boost

3. Add – DWITH_BOOST=/usr/local/boost when precompiling and installing MySQL

Compile and install MySQL

# Add MySQL users
useradd -s /sbin/nologin -M mysql
# Download MySQL
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24.tar.gz
# Unzip MySQL
tar zxvf mysql-5.7.24.tar.gz
# Go into the MySQL directory
cd mysql-5.7.24
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.7.24 \
-DWITH_BOOST=/usr/local/boost \
-DMYSQL_UNIX_ADDR=/usr/local/mysql-5.7.24/tmp/mysql.sock \
-DMYSQL_DATADIR=/usr/local/mysql-5.7.24/data \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_ZLIB=bundled \
# Compile & Install
make && make install

To configure

# Creating Soft Connections
cd /usr/local
ln -s mysql-5.7.24 mysql
# Add to environment variables
vim /etc/profile
export PATH=/usr/local/mysql/bin:$PATH
export PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
source /etc/profile
cd /usr/local/mysql-5.7.24
mkdir -p /usr/local/mysql-5.7.24/{data,tmp,logs,pids}
chown mysql.mysql /usr/local/mysql-5.7.24/data
chown mysql.mysql /usr/local/mysql-5.7.24/tmp
chown mysql.mysql /usr/local/mysql-5.7.24/logs
chown mysql.mysql /usr/local/mysql-5.7.24/pids
# Modify the / etc / my. CNF file to edit the configuration file as follows
# Create mysqld. log and mysqld. PID files
touch /usr/local/mysql/logs/mysqld.log
touch /usr/local/mysql/pids/mysqld.pid
chown mysql.mysql -R /usr/local/mysql/logs/
chown mysql.mysql -R /usr/local/mysql/pids/
# Join the daemon
cd /usr/local/mysql
cp support-files/mysql.server /etc/init.d/mysqld
chmod a+x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
# Initialize the database, - initialize means that a secure password is generated by default, - initialize - insecure means no password is generated.
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# Start MySQL
service mysqld start

Here’s a configuration diagram for / etc / my. CNF

CentOS 7 Compiler and Installation of MySQL 5.7.24

Log on to MySQL and change password

Mysql-u root-p# No password is required for the first landing, just return.
Set password for [email protected] = password ('root');#Modify password


The above is a detailed tutorial on compiling and installing MySQL 5.7.24 for entOS 7 introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support to developpaer.