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

Solutions to MySql crash and service failure to start

I have been in contact with PHP for so long, but ...

MySQL-8.0.26 Configuration Graphics Tutorial

Preface: Recently, the company project changed th...

How to quickly modify the root password under CentOS8

Start the centos8 virtual machine and press the u...

MySQL subqueries and grouped queries

Table of contents Overview Subqueries Subquery Cl...

Introduction to JavaScript conditional access attributes and arrow functions

Table of contents 1. Conditional access attribute...

HTML page jump passing parameter problem

The effect is as follows: a page After clicking t...

The vue project realizes drawing a watermark in a certain area

This article shares with you how to use Vue to dr...

Basic principles of MySQL scalable design

Table of contents Preface 1. What is scalability?...

Detailed explanation of non-parent-child component communication in Vue3

Table of contents First method App.vue Home.vue H...

jQuery implements navigation bar effect with expansion animation

I designed and customized a navigation bar with a...

Detailed tutorial on installing the jenkins container in a docker environment

Recommended Docker learning materials: https://ww...

A brief discussion on MySQL user permission table

MySQL will automatically create a database named ...

Better looking CSS custom styles (title h1 h2 h3)

Rendering Commonly used styles in Blog Garden /*T...

How to encapsulate the carousel component in Vue3

Purpose Encapsulate the carousel component and us...

Comparative Analysis of High Availability Solutions of Oracle and MySQL

Regarding the high availability solutions for Ora...