Detailed tutorial on compiling and installing MySQL 5.7.24 on CentOS7

Detailed tutorial on compiling and installing MySQL 5.7.24 on CentOS7

Install Dependencies

(1) cmake is the 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 CentOS7, but not in CentOS6: sudo yum install perl perl-devel autoconf

Install boost

If you install MySQL 5.7 or above, you need to install boost before compiling and installing it, because higher versions of MySQL require the installation of the boots library to run normally. Otherwise, CMake Error at cmake/boost.cmake:81 will be reported

1. Switch to the /usr/local directory and download boost in this directory

MySQL 5.7.24 requires boost version 1.59. Higher versions are not applicable to 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. When precompiling and installing MySQL, add -DWITH_BOOST=/usr/local/boost

Compile and install MySQL

# Add MySQL user 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 to the MySQL directory cd mysql-5.7.24
# Precompile 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

Configuration

# Create a soft link 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 and 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 process 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 that no password is generated. mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# Start MySQL
service mysqld start

Here is a diagram of the configuration of /etc/my.cnf


Log in to MySQL and change the password

mysql -u root -p #No password is required for the first login, just press Enter set password for root@localhost = password('root'); #Change password

Summarize

The above is a detailed tutorial on how to compile and install MySQL5.7.24 on CentOS7. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • Centos7.5 installs mysql5.7.24 binary package deployment
  • The perfect solution for MYSQL5.7.24 installation without data directory and my-default.ini and service failure to start
  • Detailed graphic description of the database installation process of MySQL version 5.7.24
  • MySQL 5.7.24 installation and configuration graphic tutorial
  • MySQL 5.7.24 installation and configuration method graphic tutorial
  • How to install mysql5.7.24 binary version on Centos 7 and how to solve it
  • Summary of installation steps and problems encountered in decompressing the mysql5.7.24 version
  • MySQL 5.7.24 compressed package installation and configuration method graphic tutorial

<<:  How to install mongodb 4.2 using yum on centos8

>>:  Using better-scroll component in Vue to realize horizontal scrolling function

Recommend

Linux View File System Type Example Method

How to check the file system type of a partition ...

JS operation object array to achieve add, delete, modify and query example code

1. Introduction Recently, I helped a friend to ma...

A mobile adaptive web page effect solves the problem of small display page

For work needs, I need to make a mobile phone adap...

Ideas for creating wave effects with CSS

Previously, I introduced several ways to achieve ...

Docker installation of Nginx problems and error analysis

question: The following error occurred when insta...

Example code for text origami effect using CSS3

Preface This article mainly shares with you an ex...

Implementation of HTML command line interface

HTML Part Copy code The code is as follows: <!D...

How to use Vue cache function

Table of contents Cache function in vue2 Transfor...

How to use mysql to complete the data generation in excel

Excel is the most commonly used tool for data ana...

How to decrypt Linux version information

Displaying and interpreting information about you...

CSS stacking and z-index example code

Cascading and Cascading Levels HTML elements are ...

Detailed explanation of three ways to connect Docker containers to each other

There are three ways to interconnect and communic...

SQL serial number acquisition code example

This article mainly introduces the sql serial num...