Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The process of compiling and installing MySQL5.7.16 source code

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains the "MySQL5.7.16 source code compilation and installation process", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn the "MySQL5.7.16 source code compilation and installation process" bar!

Installation environment: CentOS7 64-bit

I. installation conditions of the system

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 the source code to set the compilation parameters of mysql. Such as: installation directory, data storage directory, character encoding, sorting rules and so on. Just install the latest version.

2 > make3.75

The mysql source code is written in C and C++ language. Make is used to compile and build the source code under linux. Make 3.75 or above is required.

3 > gcc4.4.6

GCC is a C language compilation tool under Linux. Mysql source code compilation is written entirely in C and C++. GCC4.4.6 or above is required.

4 > Boost1.59.0

The Boost library of C++ is used in the mysql source code, which requires that boost1.59.0 must be installed. If the version does not match, an error will be reported, resulting in compilation failure. The source location is specified with the parameter WITH_BOOST at compile time.

5 > enough memory

When compiling large source files, you may encounter a "internal compiler error" error if you run out of memory

6 > Perl

If you want to run test scripts, you need Perl

7 > bison2.1

If you encounter a problem with the CAccord Candle + parser under Linux, please upgrade to a later version instead of reverting to the previous version.

8 > ncurses ncurses-devel

Character terminal processing library

So before installing, check the relevant dependent libraries:

Rpm-Q-- queryformat "% {NAME} -% {VERSION} -% {RELEASE} (% {ARCH})\ n"\

Cmake\

Make\

Gcc\

Ncurses\

Ncurses-devel\

Bison\

| | grep "not installed"

Packages required for yum-y install installation

Download the Boost1.59.0 source code and extract 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/

Download the MySQL source code

Download the source code of mysql 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, perform the yum install-y git installation.

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 another version, you can switch to the corresponding branch. If you install version 5.6: git checkout 5.6, take installation 5.7 as an example.

3. Install 1 > add mysql users

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 collation

-DENABLED_LOCAL_INFILE: allow data to be imported from this file

-DEXTRA_CHARSETS: install all character sets

If cmake fails, you need to delete the generated CMakeCache.txt file.

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 at compile time based on the number of CPU cores, which can speed up compilation. The default is 1 thread compilation. After testing the memory of single-core CPU,1G, it takes nearly 1 hour to compile.

4 > initialize the system database

Shell > cd / usr/local/mysql

Create a directory whose location can be provided to the secure_file_priv system variable, which restricts import / export operations to that specific directory

Shell > mkdir mysql-files

Shell > chmod 750mysql-files

Shell > chown-R mysql:mysql mysql-files

# Note: MySQL versions prior to 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

# version of the initial system database script after 5.7.6 (this article uses this method to initialize)

Shell >. / mysqld-initialize-user=mysql

2018-10-26T08:53:47.890293Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-explicit_defaults_for_timestamp server option (see documentation for more details).

2018-10-26T08:53:47.891867Z 0 [ERROR] COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET' latin1'

2018-10-26T08:53:47.892012Z 0 [ERROR] Aborting

If an error is found, the solution is to add encoding parameters to the configuration file:

[client]

Default-character-set = utf8 # newly added parameter

[mysqld]

Basedir = / opt/app/mysql/mysql5716

Datadir = / opt/app/mysql/mysql5716/data

Port = 3306

Socket = / opt/app/mysql/mysql5716/mysqld.sock

Character-set-server = utf8 # newly added parameter

Add it and reinitialize it. After initialization, mysql creates a 'root'@'localhost' account to log in.

# initialize SSL

Shell >. / bin/mysql_ssl_rsa_setup

Note: after initializing the system database with the-initialize parameter, a temporary password for the root user is generated in the ~ / .mysql_secret file and printed in the initialization log, as shown in the red circle below:

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 the system service

Shell > chkconfig mysqld on # Boot

7. Start the service

Shell > service mysqld start # start the mysql service

Shell > service mysqld stop # stop the mysql service

Shell > service mysqld restart # restart the mysql service

Or

Shell > bin/mysqld_safe-- user=mysql &

If there is a startup error, check the error log solution. The default is the host_name.err file under data directory.

8. Reset the database password after login

The default password generated after initialization must be reset before you can use mysql

Shell > alter user 'root'@'localhost' identified by' xxx'

9. Configure mysql environment variables

Shell > vi / etc/profile

Shell > export PATH=/usr/local/mysql/bin:$PATH

Shell > source / etc/profile

Thank you for reading, the above is the content of "MySQL5.7.16 source code compilation and installation process", after the study of this article, I believe you have a deeper understanding of the process of MySQL5.7.16 source code compilation and installation, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report