1, pre-installation preparation work
1.1 Essential Packages
gcc/g++: MySQL 5.6 starts and needs to be compiled with g++.
Starting with Cmake:mysql 5.5, CMake is used for project management, and CMake requires more than 2.8 versions.
The BISON:MYSQL syntax parser needs to be compiled with bison.
Ncurses-devel: A development package for terminal operations.
1.2 MySQL compilation parameters
Cmake_build_type compiled version type: Relwithdebinfo and debug, the difference is that Relwithdebinfo will be optimized.
CMAKE_INSTALL_PREFIX Specifies the destination path for the make install installation.
SYSCONFDIR Specifies the default path for the configuration file.
MYSQL_DATADIR Specifies the default path for the data directory.
WITH_DEBUG Specifies whether there is debugging information, commonly used for source debugging, open with_debug, production environment shutdown.
enabled_profiling Specifies whether the show profile can be used to display the details of the operation execution.
DEFAULT_CHARSET Specifies the default character set, which can be specified in the startup configuration file.
default_collation Specifies the default character comparison, sorting rules.
WITH_EXTRA_CHARSETS specifies the other possible character sets that may be used.
WITH_SSL Specifies the type of SSL, starting with the default bundled type from 5.6.6, and optionally specifying the path address of the SSL library.
WITH_ZLIB Specifies the type of ZLIB to use for compression functions.
ENABLED_LOCAL_INFILE Specifies whether the load data INFILE feature is allowed.
WITH_EMBEDDED_SERVER Specifies whether to compile the Libmysqld embedded library.
INSTALL_LAYOUT Specifies the type of layout to install.
WITH_STORAGE_STORAGE_ENGINE Specifies the storage engine supported by the compilation, and the Myisam,merge,memory,csv storage engine is supported by default.
1.3 This installation environment
Server version: CentOS 6.4
MySQL version: 5.6.24.tar.gz
The installation directory is:/app/soft/mysql
The Data directory is:/data/mysqldata
Storage engines include: MEMORY,MYISAM,INNODB, etc.
The character set is: UTF8
2, source installation MySQL
2.1 Install the required libraries first:
Yum-y Install GCC gcc-c++
Yum-y Install Ncurses-devel
2.2 Download the required packages:
#将下载的文件都放到 The/USR/LOCAL/SRC directory, the following
# CD/USR/LOCAL/SRC
# wget http://www.cmake.org/files/v3.2/cmake-3.2.0.tar.gz
# wget http://ftp.gnu.org/gnu/bison/bison-2.7.tar.gz
# wget http://ftp.gnu.org/gnu/m4/m4-1.4.16.tar.gz
# wget http://www.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz/from/http://cdn.mysql.com/
Installing the CMake Compiler
# CD/USR/LOCAL/SRC
# TAR-XVF Cmake-3.2.0.tar.gz
# CD cmake-3.2.0
#./bootstrap
# Make && make install
Installing M4
# CD/USR/LOCAL/SRC
# TAR-XVF M4-1.4.16.tar.gz
# CD m4-1.4.16
#./configure && make && make install
Installing Bison
# CD/USR/LOCAL/SRC
# TAR-XVF Bison-2.7.tar.gz
# CD bison-2.7
#./configure && make && make install
Create MySQL users and groups, related directories
#/usr/sbin/groupadd MySQL
#/usr/sbin/useradd-g MySQL MySQL
# mkdir-p/app/soft/mysql
# Chown-r Mysql:mysql/app/soft/mysql
# mkdir-p/data/mysqldata
# Chown-r mysql:mysql/data/mysqldata/
Install MySQL
# CD/USR/LOCAL/SRC
# TAR-XVF Mysql-5.6.12.tar.gz
# export cflags= "-o3-g-fno-exceptions-static-libgcc-fno-omit-frame-pointer-fno-strict-aliasing"
# export cxxflags= "-o3-g-fno-exceptions-fno-rtti-static-libgcc-fno-omit-frame-pointer-fno-strict-aliasing"
# Export cxx=g++
# CD mysql-5.6.12
# Cmake-dcmake_install_prefix=/app/soft/mysql
-dmysql_unix_addr=/tmp/mysql.sock
-ddefault_charset=utf8
-ddefault_collation=utf8_general_ci
-dwith_extra_charsets=utf8
-dwith_perfschema_storage_engine=1
-dwith_federated_storage_engine=1
-dwith_partition_storage_engine=1
-dwith_archive_storage_engine=1
-dmysql_datadir=/data/mysqldata/
-dsysconfdir=/app/soft/mysql/
-dwith_ssl=bundled
-denabled_local_infile=1
-dwith_innobase_storage_engine=1
-dwith_blackhole_storage_engine=1
-denable_downloads=1
Precautions:
When you recompile, you need to clear the old object file and cache information.
# Make Clean
# rm-f CMakeCache.txt
# RM-RF/ETC/MY.CNF
# Make && make install
Initializing the database
# cd/app/soft/mysql/
#./scripts/mysql_install_db--user=mysql--datadir=/data/mysqldata
3, after the installation of the finishing work
Configuring the Operating Environment
# Vi/etc/profile
# Path=/app/soft/mysql/bin:/app/soft/mysql/lib: $PATH
# Export PATH
# Source/etc/profile
Create a boot boot
# CP SUPPORT-FILES/MY-DEFAULT.CNF/ETC/MY.CNF//can also copy my.cnf directly to the installation file location
# CP Support-files/mysql.server/etc/init.d/mysqld
# chkconfig--level mysqld on//boot start
# service Mysqld Start
Modifying the MY.CNF configuration file
Note Startup failure
Check the permissions of the directory/data/mysqldata that stores the database data, and if it is root.root, you need to modify it to Mysql.mysql
Check that the configuration file/etc/my.cnf is configured for the DataDir parameter:/data/mysqldata
Login account, first login without password
# mysql-uroot-p
If the report Mysql:command not found
Cause: This is because the system will find the command under/usr/bin by default, if this command is not in this directory, of course, will not find the command, we need to do is to map a link to the/usr/bin directory, equivalent to create a link file.
The first thing you need to know is the full path to the MySQL command or mysqladmin command, such as the path to MySQL:/usr/local/mysql/bin/mysql, we can execute the command like this:
# ln-s/usr/local/mysql/bin/mysql/usr/bin
This essay mainly refer to: http://www.linuxidc.com/Linux/2013-07/87640.htm
CentOS 6.4 Source Installation MySQL 5.6