In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to install MySQL source code, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Two methods of source code installation
There are two ways to install the source code of MySQL.
Use a standard MySQL source distribution, this method is actually download the source code package, and then build the deployment through cmake.
For example, the source code package of version 5.6 can be downloaded by referring to the link:
For more information on how to install https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.35.tar.gz, please refer to:
Http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html only needs to change the corresponding version of MySQL 5.7, but the difference is not very big.
Or go to the official website and click to download it.
The detailed steps of the installation will be described in detail later, and most of the source code installations seen on the website so far are in this way.
Use a MySQL development tree, which compiles the deployment by developing the source tree. The main way is based on git.
In this way, relatively speaking, it feels like participating in the development of a project, with very good version management.
First use git to open the installation, which will be crawled from github.
The process of # git clone https://github.com/mysql/mysql-server.git will take some time, and how big the directory will become when it is finished. About 1.5g, and the source code compression package is about dozens of M, the difference is very big.
# du-sh.
1.5G. We use git to check the version and find that the code of MySQL 8.0 can also be crawled. If you want to try something new and master the new features of the new version, this way is more efficient.
# git branch-r
Origin/5.5
Origin/5.6
Origin/5.7
Origin/8.0
Origin/HEAD-> origin/5.7
Origin/cluster-7.2
Origin/cluster-7.3
Origin/cluster-7.4
Origin/cluster-7.5, for example, we chose version 5.7.
# git checkout 5.7
Checking out files: 100% (21703 / 21703), done.
What happens next in Switched to branch '5.7' is pretty much the same as installing the source package. Let's put it together.
Let's take a look at a few commands that are installed.
In fact, the steps of installing the source code are still very routine, and the time is all in the process of compilation, and you can see the log output on the screen, which feels like you are doing something super advanced. In fact, the people who write this software are really awesome, do not believe you think about your installation, in addition to cmake, make, make install, the operation steps are also much easier.
In fact, many open source software installations are steps like make,make install, what happens after this process.
The details of using make commands are as follows:
Make [options] [targets] [VAR=VALUE]...
[options] is a command line option, which can be viewed with the make-- help command, [VAR=VALUE] specifies environment variables on the command line, and target is the rule in Makefile. Sometimes I can't understand the contents of Makefile.
You can refer to this, and this list is quoted from: http://mp.weixin.qq.com/s/rp50qrNipmdBBOyNTkGJoQ
AR function library packaging program, you can create static library .a documents. Default is "ar". AS assembler. Default is "as". CC C compiler. Default is "cc". CXX C++ compiler. The default is "glossy +". CPP Cpico Clippers + preprocessor. The default is "$(CC)-E". FC Fortran compiler. The default is "f77". PC Pascal language compiler. Default is "pc". YACC Yacc grammar parser. Default is "yacc". The command line arguments of the ARFLAGS function library packager. The default is "rv". Command line arguments to the ASFLAGS assembler. Command line arguments to the CFLAGS C compiler. Command line arguments to the CXXFLAGS C++ compiler. Command line arguments to the CPPFLAGS Cpico + preprocessor. Command line arguments to the FFLAGS Fortran compiler. Command line arguments to the PFLAGS Pascal compiler. Command line arguments to the YFLAGS Yacc parser. Command line arguments to the LDFLAGS linker. Prefix / usr/localexec_prefix $(prefix) bindir $(exec_prefix) / binsbindir $(exec_prefix) / sbinlibexecdir $(exec_prefix) / libexecdatadir $(prefix) / sharesysconfdir $(prefix) / etcsharedstatedir $(prefix) / comlocalstatedir $(prefix) / varlibdir $(exec_prefix) / libinfodir $(prefix) / infoincludedir $(prefix) / includeoldincludedir $(prefix) / includemandir $(prefix) / mansrcdir the directory where the source files need to be compiled, without default
This may make it clearer, or at least we know what we are going to do.
Preparation before installation
Before installation, do the following things. Create mysql user groups, create mysql users.
Groupadd mysql
Useradd-r-g mysql-s / bin/false mysql takes some work to do next, which is the environment-dependent installation package.
For MySQL 5.7, boost is required, otherwise it cannot be compiled, so the deployment can be downloaded. Of course, boost is not required in MySQL 5.6.
Wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
Tar-zxvf boost_1_59_0.tar.gz-C / usr/local/ also has a character terminal processing library ncurses that must be checked and can be downloaded like this.
Download http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.8.tar.gz and use. / configure,make,make install to install it.
After installation, you can use the following ways to detect whether the installation is successful.
# ll / usr/lib/libncurse*
-rw-r--r-- 1 root root 669034 Mar 23 13:31 / usr/lib/libncurses.a
-rw-r--r-- 1 root root 166630 Mar 23 13:31 / usr/lib/libncurses++.a
-rw-r--r-- 1 root root 3501680 Mar 23 13:31 / usr/lib/libncurses_g.an if you're interested, you can write a short piece of code to detect it.
# include
# include
# include
Int main ()
{
Initscr ()
Move (5,15)
Printw ("% s", "Hello world")
Refresh ()
Sleep (2)
Endwin ()
Exit (EXIT_SUCCESS)
} you can run it this way.
Gmail + a.c-lncurses & &. / a.out if you see Hello world, it proves that there is no problem with the installation.
The most important thing is to make sure that cmake is available, and if not, install yum install cmake.
At the same time, the version of gcc,bison should also be noted that it should not be too low.
Source code installation
At present, there are many supported versions of cmake after decompressing the compressed package.
# ll / root/soft/mysql_source_code/mysql-5.6.35/cmake/os
Total 60
-rw-r--r-- 1 7161 31415 1402 Nov 28 21:36 AIX.cmake
-rw-r--r-- 1 7161 31415 773 Nov 28 21:36 Cygwin.cmake
-rw-r--r-- 1 7161 31415 951 Nov 28 21:36 Darwin.cmake
-rw-r--r-- 1 7161 31415 1139 Nov 28 21:36 FreeBSD.cmake
-rw-r--r-- 1 7161 31415 1714 Nov 28 21:36 HP-UX.cmake
-rw-r--r-- 1 7161 31415 1658 Nov 28 21:36 Linux.cmake
-rw-r--r-- 1 7161 31415 838 Nov 28 21:36 OS400.cmake
-rw-r--r-- 1 7161 31415 4242 Nov 28 21:36 SunOS.cmake
-rw-r--r-- 1 7161 31415 14652 Nov 28 21:36 WindowsCache.cmake
-rw-r--r-- 1 7161 31415 8011 Nov 28 21:36 Windows.cmake we started to install, it is worth mentioning that I intend to install multiple versions on the same server, so I specified a different installation directory and data directory under / usr.
Cmake.
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql_5.6
-DMYSQL_DATADIR=/home/mysql_5.6
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DENABLED_LOCAL_INFILE=1 is generally well prepared, and this process takes minutes. If ncures is not installed, it may throw the following error to exit.
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:85 (MESSAGE):
Curses library not found. Please install appropriate package, next is the make operation, we can make some improvements, that is to speed up the compilation, use the-j parameter to specify the number of threads at compile time according to the number of CPU cores, because the default is 1 thread compilation, if you do not know how many should be enabled, you can convert them.
Make-j `grep processor / proc/cpuinfo | wc-l`
The compilation log is full of screens, which looks like a sense of accomplishment.
After the make phase is done, it is make install, which will formally install the software to the specified directory, which is our ultimate goal.
It is worth mentioning that if you exit abnormally due to space problems, it is best to delete the CMakeCache.txt file, cmake it again, and then make,make install
Create a database
The work at this stage is very routine, let's simplify it, initialize the two commands and start the database.
The enabled parameter template is similar to:
[mysqld]
# server configuration
Datadir=/home/mysql_5.7
Basedir=/usr/local/mysql_5.7
Port=3308
Socket=/home/mysql_5.7/mysql.sock
Server_id=3308
Gtid_mode=ON
Enforce_gtid_consistency=ON
Master_info_repository=TABLE
Relay_log_info_repository=TABLE
Binlog_checksum=NONE
Log_slave_updates=ON
Log_bin=binlog
Binlog_format=ROW
Innodb_log_file_size=1000M
Max_prepared_stmt_count=150000
Max_connections = 3000
The operation of innodb_buffer_pool_size = 24G5.7 is as follows:
Initialize the data dictionary:
/ usr/local/mysql_5.7/bin/mysqld-- initialize-insecure-- user=mysql-- basedir=/usr/local/mysql_5.7-- datadir=/home/mysql_5.7 launch database:
/ usr/local/mysql_5.7/bin/mysqld_safe-defaults-file=/home/mysql_5.7/s.cnf &
5.6 is as follows:
Initialize data dictionary
/ usr/local/mysql_5.6/s/mysql_install_db-- user=mysql-- basedir=/usr/local/mysql_5.6-- datadir=/home/mysql_5.6 startup database
/ usr/local/mysql_5.6/bin/mysqld_safe-- defaults-file=/home/mysql_5.6/s.cnf & later, you know, we can connect to the source version of the database.
# / usr/local/mysql_5.7/bin/mysql-socket=/home/mysql_5.7/mysql.sock-port=3308
Welcome to the MySQL monitor. Commands end with; or g.
Your MySQL connection id is 7
Server version: 5.7.17-log Source distribution
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Enjoy
The above is all the contents of the article "how to install MySQL source code". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.