CentOS 7 Compiler and Installation of MySQL 5.7.24

Time:2019-3-25

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
Precompiler
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_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DWITH_INNODB_MEMCACHED=1 \
-DWITH_DEBUG=OFF \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DENABLED_PROFILING=ON \
-DMYSQL_MAINTAINER_MODE=OFF \
-DMYSQL_TCP_PORT=3306
# 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
[mysqld]
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
datadir=/usr/local/mysql/data
socket=/usr/local/mysql/tmp/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/logs/mysqld.log
pid-file=/usr/local/mysql/pids/mysqld.pid
[client]
default-character-set=utf8mb4
# 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

summary

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.