Installation Environment
[Email protected] ~]# cat/etc/centos-release
CentOS Linux release 7.0.1406 (Core)
0x01 preparatory work
1, to the MySQL official website download mysql-community-5.7.11-1.el7.src.rpm Source Package
Rpm-ih MYSQL-COMMUNITY-5.7.11-1.EL7.SRC.RPM will generate a rpmbuild in the user directory, from the Sources folder can obtain the source code mysql-5.7.11.tar.gz, unzip into the source directory ready to install
2, because MySQL needs to use CMake compile, directly from Yum from the source of the CD to find CMake
[email protected] ~]# Yum info cmake
Name: CMake
Architecture: x86_64
Version: 2.8.11
Release: 4.el7
Size: 6.7 M
3. Prepare for development environment Yum Groupinstall Additional Development,yum groupinstall Development tools
Previous versions are development tools and development libraries two package groups
0x02 MySQL Compilation options
Some common compilation options
-dcmake_install_prefix=/usr/local/mysql [MySQL installation root directory]-dmysql_datadir=/mydata/mysql/data [MySQL database file storage directory]-dsysconfdir=/etc [mysql config file directory]-dmysql_user=mysql [MySQL user name]-dwith_myisam_storage_engine=1 [MySQL database engine]-dwith_i nnobase_storage_engine=1 [MySQL Database engine]-dwith_archive_storage_engine=1 [ MySQL database engine]-dwith_memory_storage_engine=1 [MySQL database engine]-dwith_readline=1 [MySQL ReadLine Library, Bulk import data]-dmysql_unix_addr=/var/run/mysql/mysql.sock [MySQL's Communication directory]-dwi Th-libwrap=0 [Support LibWrap]-denable_downloads=1 [compile-time allow autonomous download of related files]-ddefa Ult_charset=utf8 [Set the default character set to Utf8]-ddefault_collation=utf8_general_ci [Set default sort character set rules]
0X03 installation process (GCC/
Boost_1_59_0/Curses_library)
Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/mymnt/sqldata-dsysconfdir=/etc-dwith_myisam_ Storage_engine=1-dwith_innobase_storage_engine=1-dwith_archive_storage_engine=1-dwith_memory_storage_engine=1- Dwith_readline=1-dmysql_unix_addr=/var/run/mysql/mysql.sock-dwith-libwrap=0-denable_downloads=1-ddefault_ Charset=utf8-ddefault_collation=utf8_general_ci
--Running CMake version 2.8.11
--Could not find Git (missing:git_executable)
--Configuring with max_indexes = 64U
--The C compiler identification is unknown
--The CXX compiler identification is unknown
CMake error:your C Compiler: "Cmake_c_compiler-notfound" is not found. Please set Cmake_c_compiler to a valid COMPILER path or name.
CMake error:your CXX Compiler: "Cmake_cxx_compiler-notfound" was not found. Please set Cmake_cxx_compiler to a valid COMPILER path or name.
CMake Error at cmake/os/linux.cmake:41 (MESSAGE):
Unsupported compiler!
Call Stack (most recent call first):
cmakelists.txt:162 (INCLUDE)
This is not installed GCC and gcc-c++
[email protected] mysql-5.7.11]# yum install gcc gcc-c++
One more cmake.
--MySQL 5.7.11
--Packaging as:mysql-5.7.11-linux-x86_64
--looked for boost/version.hpp in and
--Boost_include_dir Boost_include_dir-notfound
--Local_boost_dir
--Local_boost_zip
--Could not find (the correct version of) boost.
-- MySQL currently requires BOOST_1_59_0
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with-ddownload_boost=1-dwith_boost=<directory>
This CMake script would look-for-boost in <directory> If It is not there,
It'll download and unpack it (in this directory) for you.
If you were inside a firewall, you could need to use an HTTP proxy:
Export http_proxy=http://example.com:80
Call Stack (most recent call first):
cmake/boost.cmake:238 (Could_not_find_boost)
cmakelists.txt:443 (INCLUDE)
--Configuring incomplete, Errors occurred!
This has been explained by you can download it with -ddownload_boost=1-dwith_boost=<directory>, BOOST Library is a thoroughly tempered, portable, The C + + library that provides the source code, as a fallback to the standard library, is one of the engines of the C + + standardization process.
Download this library from the Boost official website first boost_1_59_0.tar.gz
Add directory to-dwith_boost compilation option after decompression
Continue compiling error as follows
--Could not find Curses (missing:curses_library curses_include_path)
CMake Error at cmake/readline.cmake:64 (MESSAGE):
Curses Library not found. Please install the appropriate package,
Remove CMakeCache.txt and rerun CMake. On Debian/ubuntu, package name was Libncurses5-dev, on Redhat and derivates it was ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:107 (find_curses)
cmake/readline.cmake:181 (Mysql_use_bundled_editline)
cmakelists.txt:471 (Mysql_check_editline)
This error is a description of the missing curses library yum install Ncurses-devel, it is important to note that each compilation error is removed CMakeCache.txt, and finally the build files have been written That success
CMake Warning:
Manually-specified variables were not used by the project:
Download_boost
With-libwrap
With_memory_storage_engine
With_readline
--Build files has been written to:/root/mysql-5.7.11
Compile with make for about two hours and stay longer at 50%.
Make install
Installation is complete with a bunch of installation information
--Installing:/usr/local/mysql/mysql-test/./cmake_install.cmake
--Installing:/usr/local/mysql/mysql-test/./ctesttestfile.cmake
--Up-to-date:/usr/local/mysql/mysql-test/mtr
--Up-to-date:/usr/local/mysql/mysql-test/mysql-test-run
--Installing:/usr/local/mysql/mysql-test/lib/my/safeprocess/my_safe_process
--Up-to-date:/usr/local/mysql/mysql-test/lib/my/safeprocess/my_safe_process
--Installing:/usr/local/mysql/mysql-test/lib/my/safeprocess/base.pm
--Installing:/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-DEFAULT.CNF
--Installing:/usr/local/mysql/support-files/mysqld_multi.server
--Installing:/usr/local/mysql/support-files/mysql-log-rotate
--Installing:/usr/local/mysql/support-files/magic
--Installing:/USR/LOCAL/MYSQL/SHARE/ACLOCAL/MYSQL.M4
--Installing:/usr/local/mysql/support-files/mysql.server
[Email protected] mysql-5.7.11]#
0x04 post-installation directory creation
Socket=/var/run/mysql/mysql.sock
Basedir =/usr/local/mysql
DataDir =/mymnt/sqldata
Socket=/var/run/mysql/mysql.sock
Log-error =/var/log/mysql/error.log
Pid-file =/var/log/mysql/mysql.pid
As a configuration file about the directory-related sections, we need to create/var/run/mysql,/mymnt/sqldata,/var/log
Create MySQL users and groups, change the owner (group) of the data Catalog/mymnt/sqldata and the installation directory/var/run/mysql to MySQL
[[email protected] mysql]# groupadd-r MySQL
[[email protected] mysql]# useradd-r-g mysql-s/sbin/nologin MySQL
[Email protected] mysql]# Mkdir/var/run/mysql
[Email protected] mysql]# Mkdir/var/log/mysql
[Email protected] mysql]# chown mysql:mysql/var/run/mysql/
[Email protected] mysql]# chown mysql:mysql/var/log/mysql/
[Email protected] mysql]# chown mysql:mysql/mymnt/sqldata/
[Email protected] mysql]# chown-r mysql:mysql/usr/local/mysql
0X05 initialization
1, mysql-5.7 version of the my.cnf file under support-files/and no template file, add the configuration file yourself
2. Copy the Support-files/mysql.server startup script from the installation directory to the/ETC/INIT.D/MYSQLD to enable booting. You can also [[email protected] mysql]#./support-files/mysql.server Start Temporary launch
Executing the MySQL command when it is not started will error the following:
[[email protected] mysql]# MySQL
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/run/mysql/mysql.sock ' (2)
3. Add environment variable to use initialization command export Path=/usr/local/mysql/bin:$PATH
4. Initialization
Mysqld--initialize-insecure--user=mysql--basedir=/usr/local/mysql--datadir=/mymnt/sqldata
0x06 Other
1, Mysqld_safe
Both Mysqld and Mysqld_safe can start MySQL. The method of running the MYSQLD program directly to start the MySQL service is rarely seen, and the Mysqld_safe script will continue to monitor its operation after starting the MySQL server and restart it when it dies.
We can see that this is a shell script, and it is recommended to use Mysqld_safe to start the MYSQLD Server in UNIX and NetWare. Mysqld_safe adds some security features, such as restarting the server and writing run time information to the error log file when an error occurs.
[[Email protected] mysql]# file Bin/mysqld
Bin/mysqld:elf 64-bit LSB executable, x86-64, version 1 (gnu/linux), dynamically linked (uses shared libs), for Gnu/linux 2.6.32, buildid[sha1]=0x772828c9d330090391cd89dbe699f041a378944d, not stripped
[[Email protected] mysql]# file Bin/mysqld_safe
Bin/mysqld_safe:posix shell script, ASCII text executable
2, Mysql_secure_installation
MySQL Security Configuration Wizard, running Mysql_secure_installation will perform several settings:
A) set a password for the root user
b) Delete Anonymous account
c) Remove the root user from remote login
d) Delete the test library and access to the test library
e) Refresh the authorization form for the changes to take effect
These settings can improve the security of the MySQL library. Recommended MySQL installation in a production environment you must run the mysql_secure_installation once this is done
3, in order to facilitate other program calls (such as PHP), the MySQL database dynamic link library directory added to the System link library, echo "/usr/local/mysql/lib" >/etc/ld.so.conf.d/mysql.conf
0x07 Attached: my.cnf example
Baidu to a sample MySQL configuration file:
# for advice The change settings see# http://dev.mysql.com/doc/refman/5.7/en/ server-configuration-defaults.html# * * * does not EDIT the this FILE. It's a template which'll be copied to the# * * * default location during install, and would be replaced if you# * * * Upgrade To a newer version of MySQL. [client]port=3306socket=/var/run/mysql/mysql.sock[mysqld]# Remove leading # and set to the amount of RAM for the most impo Rtant data# Cache in MySQL. Start at 70% of all RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128m# Remove Leading # to turn on a V ery important data Integrity option:logging# changes to the binary log between backups.# log_bin# These is commonly set, Remove the # and set as Required.user = Mysqlbasedir =/usr/local/mysqldatadir =/mydata/mysql/dataport=3306server-id = 1 Socket=/var/run/mysql/mysql.sockcharacter-set-server = Utf8log-error =/var/log/mysql/error.logpid-file =/var/log/ Mysql/mysql.pidgeneral_log = 1skip-name-resolve#skip-networkingbaCk_log = 300max_connections = 1000max_connect_errors = 6000open_files_limit = 65535table_open_cache = Max_allowed_pac Ket = 4mbinlog_cache_size = 1mmax_heap_table_size = 8mtmp_table_size = 16mread_buffer_size = 2Mread_rnd_buffer_size = 8Mso Rt_buffer_size = 8mjoin_buffer_size = 28mkey_buffer_size = 4mthread_cache_size = 8query_cache_type = 1query_cache_size = 8 Mquery_cache_limit = 2mft_min_word_len = 4log_bin = Mysql-binbinlog_format = Mixedexpire_logs_days = 30performance_ schema = 0explicit_defaults_for_timestamp#lower_case_table_names = 1myisam_sort_buffer_size = 8Mmyisam_repair_ Threads = 1interactive_timeout = 28800wait_timeout = 28800# Remove Leading # To set options mainly useful for reporting SE rvers.# the server defaults is faster for transactions and fast selects.# Adjust sizes as needed, experiment to find the Optimal values.# join_buffer_size = 128m# Sort_buffer_size = 2m# read_rnd_buffer_size = 2m# disabling symbolic-links is re Commended to prevent assorted security riskssymbolic-links=0# Recommended in standard MySQL setupsql_mode=no_engine_substitution,no_auto_create_user,strict_ Trans_tables[mysqldump]quickmax_allowed_packet = 16m[myisamchk]key_buffer_size = 8Msort_buffer_size = 8Mread_buffer = 4mwrite_buffer = 4M
CENTOS7 mysql-community-5.7.11 Compile and install