Source code compilation on CentOS 7 install MySQL 5.7

Source: Internet
Author: User
Tags deprecated mysql version

1. System environment

[Email protected] ~]# uname-r

3.10.0-514.el7.x86_64


[Email protected] ~]# cat/etc/redhat-release

CentOS Linux release 7.3.1611 (Core)


[Email protected] ~]# Rpm-qa | grep mariadb

Mariadb-libs-5.5.52-1.el7.x86_64


[Email protected] ~]# rpm-e--nodeps mariadb-libs [[email protected] ~]# [[email protected] ~]# Yum install-y GC C Gcc-c++ Perl


2. Installing dependent Packages


The role of related dependency packages

CMake: Since the general Configure compilation method is deprecated from the MySQL5.5 version, the CMake compiler is required to set the compilation parameters for MySQL. such as: installation directory, data storage directory, character encoding, sorting rules, etc.
boost:#从 mysql 5.7.5 start boost library is required, MySQL source used in the C + + boost library, required to install boost1.59.0 or above version
gcc: Linux C language compiler tool, MySQL source code compiled by C and C + + written, requires the installation of GCC
Bison: Linux down-C + + syntax parser
ncurses: character Terminal processing Library


1) Installation File preparation


Download cmake-3.8.1.tar.gz Source Release Package
http://www.cmake.org/download/

wget https://cmake.org/files/v3.8/cmake-3.8.1.tar.gz


Download ncurses-6.0.tar.gz
ftp://ftp.gnu.org/gnu/ncurses/

wget ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz


Download m4-1.4.18.tar.gz

wget http://mirrors.kernel.org/gnu/m4/m4-1.4.18.tar.gz


Download bison-3.0.4.tar.gz
http://ftp.gnu.org/gnu/bison/

wget http://ftp.gnu.org/gnu/bison/bison-3.0.4.tar.gz


Download mysql-5.7.18.tar.gz

wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.18.tar.gz


Download Boost_1_59_0.tar.gz

wget https://ncu.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz



2) installation of CMAKE and necessary software


Installing CMake

[Email protected] ~]# tar zxvf cmake-3.8.1.tar.gz [[email protected] ~]# CD cmake-3.8.1 [[email protected] cmake-3.8 .1]#./bootstrap [[email protected] cmake-3.8.1]# gmake && gmake Install [[email protected] cmake-3.8.1]# cm ake-version [[Email protected] cmake-3.8.1]# CD ~


Installing M4

[Email protected] ~]# tar zxvf m4-1.4.18.tar.gz [[email protected] ~]# CD m4-1.4.18 [[email protected] m4-1.4.18]#. /configure [[email protected] m4-1.4.18]# make && make install [[email protected] m4-1.4.18]# CD ~


Install Bison (Note: Perl and M4 support required)

[Email protected] ~]# tar zxvf bison-3.0.4.tar.gz [[email protected] ~]# CD bison-3.0.4 [[email protected] bison-3.0 .4]#./configure [[email protected] bison-3.0.4]# make && make install [[email protected] bison-3.0.4]# CD ~


Installing ncurses

[Email protected] ~]# tar zxvf ncurses-6.0.tar.gz [[email protected] ~]# CD ncurses-6.0 [[email protected] ncurses-6 .0]#./configure [[email protected] ncurses-6.0]# make && make install [[email protected] ncurses-6.0]# CD ~


Install Boost (note: The correct version of the boost required for MySQL 5.7.18 is boost_1_59_0)

[Email protected] ~]# tar zxvf boost_1_59_0.tar.gz [[email protected] ~]# MV Boost_1_59_0/usr/local/boost


3. Create a MySQL user, user group, and directory

[Email protected] ~]# groupadd-r mysql && useradd-r-G mysql-s/bin/false-m MySQL [[email protected] ~]# MK dir/usr/local/mysql [[email protected] ~]# mkdir-p/data/mysql


4. Pre-compilation

[[Email protected] ~]# tar zxvf mysql-5.7.18.tar.gz    [[email  protected] ~]# cd mysql-5.7.18    [[email protected]  MYSQL-5.7.18] #cmake  . -dcmake_install_prefix=/usr/local/mysql \    -dmysql_ datadir=/data/mysql \    -dwith_boost=/usr/local/boost \     -dsysconfdir=/etc \    -dwith_innobase_storage_engine=1 \     -dwith_partition_storage_engine=1 \    -dwith_federated_storage_engine=1 \     -dwith_blackhole_storage_engine=1 \    -dwith_myisam_storage_ Engine=1 \    -denabled_local_infile=1 \    -denable_dtrace= 0 \    -ddefault_charset=utf8mb4 \    -ddefault_collation= utf8mb4_general_ci \&Nbsp;   -dwith_embedded_server=off 


5. Compiling the installation

[Email protected] mysql-5.7.18]# make-j ' grep processor/proc/cpuinfo | Wc-l ' [[email protected] mysql-5.7.18]# make install

The-j parameter indicates that the number of threads at compile time is specified based on the number of CPU cores, which speeds up compilation. The default is 1 thread compilation.


6. Set permissions and initialize MySQL system authorization Form

[Email protected] mysql-5.7.18]# cd/usr/local/mysql [[email protected] mysql]# chown-r mysql:mysql. [Email protected] mysql]# mkdir temp [[email protected] mysql]# chmod 777./temp [[email protected] mysql]# Cd/dat a/mysql [[email protected] mysql]# chown-r mysql:mysql.


MySQL 5.7.6 Previous Version execute this script initialize the system database

./bin/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/data/mysql


5.7.6 after version initial system database script

[Email protected] mysql]# cd/usr/local/mysql [[email protected] mysql]#./bin/mysqld--initialize-insecure--user=mys QL--basedir=/usr/local/mysql--datadir=/data/mysql


Attention:
Before MySQL version mysql_install_db was under Mysql_basedir/script, MySQL 5.7 was placed directly under the Mysql_basedir/bin directory.
"--initialize" is deprecated, generating a random password (~/.mysql_secret)
"--initialize-insecure" does not generate a password
Cannot have data file under "--datadir" directory

[Email protected] mysql]#./bin/mysql_ssl_rsa_setup


7. Create a configuration file

[email protected] mysql]# cat >/etc/my.cnf << EOF


[Client]
port=3306
Socket=/usr/local/mysql/mysql.sock
[Mysqld]
Character-set-server=utf8
Collation-server=utf8_general_ci

Skip-external-locking
Skip-name-resolve

User=mysql
port=3306
Basedir=/usr/local/mysql
Datadir=/data/mysql
Tmpdir=/usr/local/mysql/temp
# server_id = ...
Socket=/usr/local/mysql/mysql.sock
Log-error=/usr/local/mysql/logs/mysql_error.log
Pid-file=/usr/local/mysql/mysql.pid
open_files_limit=10240
back_log=600
max_connections=500
max_connect_errors=6000
wait_timeout=605800
#open_tables =600
#table_cache = 650
#opened_tables = 630

max_allowed_packet=32m
sort_buffer_size=4m
join_buffer_size=4m
thread_cache_size=300
Query_cache_type=1
query_cache_size=256m
Query_cache_limit=2m
query_cache_min_res_unit=16k

tmp_table_size=256m
max_heap_table_size=256m

key_buffer_size=256m
read_buffer_size=1m
read_rnd_buffer_size=16m
bulk_insert_buffer_size=64m

Lower_case_table_names=1

Default-storage-engine=innodb

innodb_buffer_pool_size=2g
innodb_log_buffer_size=32m
innodb_log_file_size=128m
Innodb_flush_method=o_direct
#####################
Thread_concurrency=32
long_query_time=2
Slow-query-log=on
Slow-query-log-file=/usr/local/mysql/logs/mysql-slow.log

[Mysqldump]
Quick
max_allowed_packet=32m

[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
Eof


8. Configure the MySQL service

[Email protected] mysql]# cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld [[email protected] MySQL] # chkconfig--add mysqld [[email protected] mysql]# chkconfig mysqld on


9. Start the service

[Email protected] mysql]# service mysqld start [[email protected] mysql]# NETSTAT-ANPT | grep mysqld


10. Configure the MySQL environment variable

[[email protected] mysql]# echo-e ' \n\nexport path=/usr/local/mysql/bin: $PATH \ n ' >>/etc/profile && Source/etc/profile


11. Set the database root user password

[Email protected] mysql]#./bin/mysql_secure_installation


12. Create additional MySQL database users

[[email protected] mysql]# mysql-uroot-p mysql> CREATE DATABASE ' testdb ' DEFAULT CHARACTER SET UTF8 COLLATE utf8_ge    Neral_ci;    Mysql> grant all privileges on testdb.* to ' Ryanxu ' @ ' percent ' identified by ' [email protected]# ';    mysql> flush Privileges; Myqsl> exit

Error Rollup:

1. If the halfway compilation fails, you need to delete the cache file of the precompiled configuration parameter generated by the CMake and make the generated file after compilation and recompile.

[[email protected] mysql-5.7.18]# make clean [[email protected] mysql-5.7.18]# rm-f CMakeCache.txt


2. If an error

MAKE[2]: * * [libmysqld/examples/mysql_client_test_embedded] Error 1
MAKE[1]: * * [Libmysqld/examples/cmakefiles/mysql_client_test_embedded.dir/all] Error 2

Plus

-dwith_embedded_server=off



This article is from the SQL Server deep Dive blog, so be sure to keep this source http://ultrasql.blog.51cto.com/9591438/1924467

Source code compilation on CentOS 7 install MySQL 5.7

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.