CentOS7.5 source code compile and install mysql5.7.29

View system version

[ root@ctos3 ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804(Core)

Download the source code package. Note that the boost library is required for mysql5.7 compilation and installation. You can download the source code package containing boost on the official website

https://dev.mysql.com/downloads/mysql/5.7.html#downloads

Prompt, if you don’t want to log in or register when downloading, just click “No” and start download

Start source code compilation and installation

#1. Install related dependencies

yum install -y gcc gcc-c++ cmake ncurses ncurses-devel bison wget openssl-devel.x86_64

#2. Create users and groups

groupadd  mysql
useradd mysql -s /sbin/nologin -M -g mysql

#3. Download mysql and decompress it, or download it and upload it using rz (package name lrzsz)

mkdir /home/demo/tools/
cd /home/demo/tools/
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.29.tar.gz
tar xf mysql-boost-5.7.29.tar.gz

#4. Configure related parameters

[ root@ctos3 tools]# cd mysql-5.7.29/[root@ctos3 mysql-5.7.29]# pwd
/home/demo/tools/mysql-5.7.29[root@ctos3 mysql-5.7.29]# cmake -DCMAKE_INSTALL_PREFIX=/application/mysql  -DMYSQL_DATADIR=/application/mysql/data -DMYSQL_UNIX_ADDR=/application/mysql/tmp/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost

Parameter introduction

DCMAKE_INSTALL_PREFIX  #Specify the installation directory of the MySQL program
DMYSQL_DATADIR         #Data file directory
DMYSQL_UNIX_ADDR       #socket file path
DDEFAULT_CHARSET       #Specify the server default character set, the default latin1
DDEFAULT_COLLATION     #Specify the default collation rules of the server, the default latin1_general_ci

#5. Compile and install

[ root@ctos3 mysql-5.7.29]# make -j 2&& make install

#- The function of the j parameter: it will take up a lot of system resources when compiling. You can specify multiple compilation commands through the -j parameter to perform parallel compilation to improve the speed. Use the following command to view the number of system CPU cores

[ root@ctos3 ~]# cat /proc/cpuinfo | grep processor |wc -l
2

#6. Create data directory and modify permissions

[ root@ctos3 mysql-5.7.29]# mkdir /application/mysql/data  #Store data directory

#7. Configure the /etc/my.cnf file

Note: There is no template file /application/mysql/support-files/my-default.cnf in version 5.7, you can add it yourself as needed

[ root@ctos3 ~]# cat /etc/my.cnf
[ mysqld]
port =3306
socket =/application/mysql/tmp/mysql.sock
user = mysql
basedir =/application/mysql
datadir =/application/mysql/data
pid-file =/application/mysql/data/mysql.pid
sql_mode='ONLY_FULL_GROUP_BY'
log_error =/application/mysql/mysql-error.log
! includedir /etc/my.cnf.d

[ client]
port =3306
socket =/application/mysql/tmp/mysql.sock

#8. Initialize the database

[ root@ctos3 support-files]# /application/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data

#9. Generate service startup script

# Set environment variables
[ root@ctos3 support-files]# echo 'export PATH=/application/mysql/bin:$PATH'>>/etc/profile
[ root@ctos3 support-files]# source /etc/profile
[ root@ctos3 support-files]# tail -1/etc/profile
export PATH=/application/mysql/bin:$PATH

# Generate startup script
[ root@ctos3 ~]# cd /application/mysql/support-files/[root@ctos3 support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[ root@ctos3 support-files]# cp mysql.server /etc/init.d/mysqld

# Start service and set self-startup
[ root@ctos3 support-files]# /etc/init.d/mysqld start
Starting MySQL. SUCCESS![root@ctos3 support-files]# chkconfig --add mysqld
[ root@ctos3 support-files]# chkconfig mysqld on

#10. Log in to MySQL (login without a password)

[ root@ctos3 ~]# mysql -uroot -p
Enter password:

#11. View version

mysql> select version();+-----------+|version()|+-----------+|5.7.29|+-----------+1 row inset(0.00 sec)

#12. set password

mysql> update mysql.user set authentication_string=password('guoke123') where user='root';
Query OK,1 row affected,1warning(0.01 sec)
Rows matched:1  Changed:1  Warnings:1

mysql> flush privileges;
Query OK,0 rows affected(0.01 sec)

Recommended Posts

CentOS7.5 source code compile and install mysql5.7.29
CentOS7.4 source code compile and install MySQL8.0
Centos7 compile and install MySQL8 problem record
Ubuntu 18.04 source code compile and install ffmpeg4.1
Install MySQL 8.x from source code under CentOS7
Centos compile and install Git
Centos compile JDK8 source code
Centos7 compile and install ntp-4.2.8p11
CentOS 6.9 compile and install python
CentOS 6 compile and install python 3
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Centos compile and install LAMP (apache-2.4.7 + mysql-5.5.35 + php 5.5.8) + Redis
CentOS7 yum install and start mysql
Compile and install LAMP under Centos 5.2
CentOS 6.x compile and install Nginx
CentOS7 compile and install L(A|N)MP environment
CentOS7 yum install and start mysql
Centos7 and centos8 install mysql5.6 5.7 8.0 so simple
Compile FFMPEG source code under CentOS7
Linux CentOS6 compile and install Pyt
CentOS7.2 install Mysql5.7.13
CentOS install mysql
CentOS7 install mysql
CentOS 7 install MySQL 5.6
CentOS8 install MySQL8.0
CentOS7 install mysql8
CentOS7 install MySQL8
centos 7.5 install mysql5.7.17
Compile and install the open source EDA tool-Surelog on CentOS8
Compile and install libmodbus library under CentOS7
Compile and install nodejs and yum in Centos8
CentOS8 deploys LNMP environment to compile and install mysql8.0.29 tutorial details
Install centos7 and connect
CentOS6.5 offline install MySQL5.6.26
Install MySQL5.7 in centos7
CentOS 7.2 Yum install MySQL 5.6
Centos7 install Mysql8 tutorial
Centos manually install mysql8
Install mysql under Centos 7
Centos7 install Mysql database
Install mysql5.1 under CentOS6.5
How to install openssh from centos 7 source code
How to install jdk1.8.0_151 and mysql5.6.38 on centos7.2.1511
Centos6.5 compile and install LNMP architecture web environment
Centos7.2 compile and install way to build phpMyAdmin
How to compile and install xdebug from source code in Ubuntu environment
Install mysql online on centos
centos7 install python3 and ipython
Centos mysql installation and configuration
Know Linux and install CentOS
centos install mysql through yum
CentOS 7 install Mono and MonoDevelop
Ubuntu 16.04 compile and install PHP 7.2
ubuntu18.04 compile and install python3.8
CentOS6.5 install Java 8 and Tomcat8
Install MySQL 8.0.16 on Linux Centos
Install MySQL under Linux (CentOS 7)
Centos6.5 install and configure mongodb
CentOS7 install python3 and pip3
CentOS7 install OracleJDK and JRE
CentOS6.5 install Java 8 and Tomcat8