MySQL 5.7.13 source code compilation, installation and configuration method graphic tutorial

MySQL 5.7.13 source code compilation, installation and configuration method graphic tutorial

Installation environment: CentOS7 64-bit MINI version

Official source code compilation and installation document: http://dev.mysql.com/doc/refman/5.7/en/source-installation.html

1. System Installation Conditions

Official documentation: http://dev.mysql.com/doc/refman/5.7/en/source-installation.html

1>cmake

MySQL uses the cmake cross-platform tool to precompile source code, which is used to set the compilation parameters of MySQL. Such as: installation directory, data storage directory, character encoding, sorting rules, etc. Just install the latest version.

2> make3.75

The MySQL source code is written in C and C++. Use make to compile and build the source code under Linux. You must install make 3.75 or above.

3> gcc4.4.6

GCC is a C language compiler under Linux. MySQL source code compilation is completely written in C and C++. It is required to install GCC4.4.6 or above.

4> Boost1.59.0

The MySQL source code uses the C++ Boost library, which requires that you install boost 1.59.0 or later.

5> bison2.1

C/C++ parser for Linux

6> ncurses

Character terminal processing library

So before installation, you need to install the relevant dependent libraries:

shell> sudo yum install -y cmake,make,gcc,gcc-c++,bison, ncurses,ncurses-devel


Download the Boost 1.59.0 source code and unzip it to the /usr/local/ directory:

shell> wget -O https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
shell> tar -zxvf boost_1_59_0.tar.gz -C /usr/local/


2. Download MySQL source code

Download the mysql source code from github

shell> cd /opt
shell> git clone https://github.com/mysql/mysql-server.git
shell> ls mysql-server

If the git client is not installed, run yum install -y git to install it.

shell> git branch -r
origin/5.5
origin/5.6
origin/5.7
origin/HEAD -> origin/5.7
origin/cluster-7.2
origin/cluster-7.3
origin/cluster-7.4
origin/cluster-7.5


The current branch defaults to version 5.7. If you want to install other versions, just switch to the corresponding branch. For example, if you want to install version 5.6: git checkout 5.6. Here we take the installation of version 5.7 as an example.

Sohu mirror download address:
http://mirrors.sohu.com/mysql/MySQL-5.5/
http://mirrors.sohu.com/mysql/MySQL-5.6/
http://mirrors.sohu.com/mysql/MySQL-5.7/

3. Installation

1> Add mysql user

shell> cd /opt/mysql-server
shell> groupadd mysql #Add mysql user group shell> useradd -r -g mysql -s /bin/false mysql #Add mysql user

2> Configure mysql precompilation parameters

shell> cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DWITH_BOOST=/usr/local/boost_1_59_0 \
-DSYSCONFDIR=/etc \
-DEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all

-DCMAKE_INSTALL_PREFIX: installation path
-DMYSQL_DATADIR: data storage directory
-DWITH_BOOST: boost source code path
-DSYSCONFDIR: my.cnf configuration file directory
-DEFAULT_CHARSET: Database default character encoding
-DDEFAULT_COLLATION: Default sorting rule
-DENABLED_LOCAL_INFILE: Allow importing data from this file
-DEXTRA_CHARSETS: Install all character sets

For more precompiled configuration parameters, please refer to the official MySQL documentation: http://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html#cmake-general-options

3> Compile and install

shell> make -j `grep processor /proc/cpuinfo | wc -l`
shell> make install

The -j parameter specifies the number of threads during compilation based on the number of CPU cores, which can speed up compilation. The default is 1 thread compilation. After testing, on a single-core CPU and 1G of memory, it takes nearly 1 hour to compile.

4> Initialize the system database

shell> cd /usr/local/mysql
shell> chown -R mysql:mysql .
# Note: For versions prior to MySQL 5.7.6, execute this script to initialize the system database shell> ./bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
# Initial system database script for versions after 5.7.6 (this article uses this method to initialize)
shell> ./bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
shell> ./bin/mysql_ssl_rsa_setup
shell> chown -R root .
shell> chown -R mysql data

Note: If you use the --initialize parameter to initialize the system database, a temporary password for the root user will be generated in the ~/.mysql_secret file and printed out in the initialization log, as shown in the red circle in the following figure:


5. Configuration file and parameter optimization

shell> cp support-files/my-default.cnf /etc/my.cnf
shell> vim /etc/my.cnf

[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=/usr/local/mysql/data
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

6. Configure MySQL service

shell> cp support-files/mysql.server /etc/init.d/mysqld
shell> chkconfig --add mysqld # Add to system services shell> chkconfig mysqld on # Start at boot

7. Start the service

shell> service mysqld start # Start MySQL service shell> service mysqld stop # Stop MySQL service shell> service mysqld restart # Restart MySQL service

8. Set the database password

shell> /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'127.0.0.1' identified by "root" with grant option;"
shell> /usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'localhost' identified by "root" with grant option;"
# Enable remote login (set host to %)
/usr/local/mysql/bin/mysql -e "grant all privileges on *.* to root@'%' identified by "root" with grant option;"


9. Configure MySQL environment variables

shell> vim /etc/profile
shell> export PATH=/usr/local/mysql/bin:$PATH
shell> source /etc/profile


4. Other matters needing attention

If the compilation fails midway, you need to delete the cache file of the pre-compilation configuration parameters generated by cmake and the file generated after make compilation, and then recompile.

shell> cd /opt/mysql-server
shell> rm -f CMakeCache.txt
shell> make clean

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • The most complete MySQL 5.7.13 installation and configuration method graphic tutorial (linux) highly recommended!
  • MySQL 5.7 and above version installation and configuration method graphic tutorial (mysql 5.7.12\mysql 5.7.13\mysql 5.7.14)
  • MySQL 5.7.13 installation tutorial under Linux environment
  • MySQL5.7.13 Environment Construction Tutorial (Unzipped Version)
  • MySQL 5.7.13 Installation and Configuration Notes (Mac OS)
  • MySQL 5.7.13 decompressed version (free installation) installation and configuration tutorial
  • MySQL 5.7.13 installation and configuration method graphic tutorial (linux)
  • MySQL 5.7.13 installation and configuration method graphic tutorial (win10)
  • mysql5.7.13.zip installation tutorial (windows)
  • MySQL 5.7.13 winx64 installation and configuration method graphic tutorial

<<:  Example of using Dockerfile to build an nginx image

>>:  jQuery realizes the shuttle box effect

Recommend

Detailed tutorial on installing ElasticSearch 6.x in docker

First, pull the image (or just create a container...

Detailed analysis of the usage and application scenarios of slots in Vue

What are slots? We know that in Vue, nothing can ...

Nginx/Httpd load balancing tomcat configuration tutorial

In the previous blog, we talked about using Nginx...

CSS implements the web component function of sliding the message panel

Hello everyone, I wonder if you have the same con...

mysql 8.0.18 mgr installation and its switching function

1. System installation package yum -y install mak...

Detailed explanation of the use of MySQL DML statements

Preface: In the previous article, we mainly intro...

Docker custom network container interconnection

Table of contents Preface –link Custom Network As...

CSS perfectly solves the problem of front-end image deformation

I saw an article in Toutiao IT School that CSS pe...

MySQL query data by hour, fill in 0 if there is no data

Demand background A statistical interface, the fr...

MySQL 1130 exception, unable to log in remotely solution

Table of contents question: 1. Enable remote logi...

How to deploy Oracle using Docker on Mac

How to deploy Oracle using Docker on Mac First in...

MySQL 5.7.31 64-bit free installation version tutorial diagram

1. Download Download address: https://dev.mysql.c...

Web design reference firefox default style

Although W3C has established some standards for HT...