Compile and install MySQL
Note: Compiling MySQL will be more resource-intensive, it is recommended to upgrade the memory to 1-2G under the virtual machine
MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently part of Oracle's product portfolio. MySQL is one of the most popular relational database management systems, and MySQL is the best RDBMS (relational database Management system) application software for WEB applications.
MySQL is a relational database management system, where relational databases store data in different tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility.
The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software uses a dual licensing policy, divided into community and commercial version, due to its small size, fast, low total cost of ownership, especially the open source, the development of the general small and medium-sized web site to choose MySQL as a database
SOURCE Package:
:
Http://cdn.mysql.com/Downloads/MySQL-5.7/mysql-5.7.19.tar.gz
Http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
MySQL from the 5.7 version, boost is required, it is recommended to bring the system's own boost library uninstall, source code compiled install high version
[Email protected] ~]# yum-y Remove boost-*
Uninstalling the system comes with MySQL
[[email protected] ~]# yum-y remove MySQL
Install the development Kit on the assembly:
[email protected] ~]# Yum groupinstall "Development Tools" "Development Libraries" –y
Resolving dependent environments
[email protected] ~]# yum install-y cmake make gcc gcc-c++ bison ncurses ncurses-devel autoconf automake zlib zlib-devel OpenSSL Openssl-devel pcre*
To create a running user:
[Email protected]~]# groupadd MySQL
[[Email protected]~]# useradd-m-s/sbin/nologin-r-g MySQL MySQL
Unzip the source package:
[Email protected] ~]# unzip-j lamp_for_centos7.4.zip
[Email protected] ~]# tar XF mysql-boost-5.7.19.tar.gz-c/usr/local/src/
[Email protected] ~]# cd/usr/local/src/mysql-5.7.19/
[Email protected] mysql-5.7.19]# Cmake-dcmake_install_prefix=/var/lib/mysql-dmysql_datadir=/var/lib/mysql/data- Dsysconfdir=/etc-dwith_myisam_storage_engine=1-dwith_innobase_storage_engine=1-dwith_memory_storage_engine=1- Dwith_readline=1-dmysql_unix_addr=/var/lib/mysql/mysql.sock-dmysql_tcp_port=3306-denabled_local_infile=1-dwith _partition_storage_engine=1-dextra_charsets=all-ddefault_charset=utf8-ddefault_collation=utf8_general_ci- Ddownload_boost=1-dwith_boost=/usr/local/src/mysql-5.7.19/boost/boost_1_59_0 && make && make Install
Make-j 4 #注:-j is used to specify the number of CPU cores to speed up compilation. Add-j 4 I compile with the 4 core, can improve the speed of compiling; Of course you have to determine how much CPU cores
To view the number of server CPU cores
[[email protected] mysql-5.7.19]# grep processor/proc/cpuinfo | Wc-l
1
The Help for these compilation parameters looks for a method:
http://www.mysql.com→→documentation→→ Select the corresponding version (5.7) installation & upgrades→→installing MySQL from Source→→mysql Source-configuration Options
The final URL https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
Dcmake_install_prefix: Specifies the installation directory of the MySQL program, default/usr/local/mysql
Default_charset: Specifies the server default character set, default Latin1
Default_collation: Specifies the default proofing rules for the server, default Latin1_general_ci
Enabled_local_infile: Specifies whether to allow load DATA INFILE to be executed locally, by default off
With_comment: Specifying compilation Notes Information
With_xxx_storage_engine: Specifies a storage engine that is statically compiled to MySQL, and the Myisam,merge,member and CSV four engines are compiled to the server by default and do not require special designation.
Without_xxx_storage_engine: Specifying a storage engine that does not compile
Sysconfdir: Initialize parameter file directory
Mysql_datadir: Data Files directory
Mysql_tcp_port: Service port number, default 3306
Mysql_unix_addr:socket file path, default/tmp/mysql.sock
Modify Directory Permissions
[Email protected] mysql-5.7.19]# chown-r mysql:mysql/var/lib/mysql/
Build configuration file
Backup configuration file
[[email protected] mysql-5.7.19]# Mv/etc/my.cnf{,.bak}
Create your own MY.CNF configuration file
[Email protected] mysql-5.7.19]# VIM/ETC/MY.CNF
[Mysqld]
Basedir=/var/lib/mysql Installation Path
Datadir=/var/lib/mysql/data Database Storage Directory
Port=3306 Specifying ports
Socket=/var/lib/mysql/mysql.sock
Symbolic-links=0
Character-set-server=utf8 Character Set
Log-error=/var/log/mysqld.log error Log
#pid-file=/var/run/mysqld/mysqld.pid
[MySQL]
Socket=/var/lib/mysql/mysql.sock
[Client]
Socket=/var/lib/mysql/mysql.sock
#sql_mode =no_engine_substitution,strict_trans_tables
To generate a startup script:
[Email protected] ~]# Cp/var/lib/mysql/support-files/mysql.server/etc/init.d/mysqld
[Email protected] ~]# chmod +x!$
chmod +x/etc/init.d/mysqld
[Email protected] ~]# chkconfig--add mysqld
[Email protected] ~]# chkconfig mysqld on
Delete files from the Data directory:
[Email protected] ~]# cd/var/lib/mysql/data/
[Email protected] data]# RM-RF *
Initial MySQL
[[email protected] data]/var/lib/mysql/bin/mysqld--initialize-insecure--user=mysql--basedir=/var/lib/mysql-- Datadir=/var/lib/mysql/data
Configuring Environment variables
[Email protected] ~]# Vim/etc/profile
Export Mysql_home=/var/lib/mysql
Export path= $PATH: $MYSQL _home/bin
Make the changes effective
[Email protected] ~]# Source/etc/profile
Or:
[Email protected] ~]# ln-s/var/lib/mysql/bin/*/usr/local/bin/
Start the service:
[[email protected] data]#/etc/init.d/mysqld start
Starting MySQL. success!
Login Error:
[[email protected] ~]# MySQL
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:no)
Workaround: Locate the MySQL installation path and log in to MySQL in the path
[Email protected] support-files]# cd/var/lib/mysql/bin/
[Email protected] bin]#./mysql-p
Enter Password:
mysql> set password for ' root ' @ ' localhost ' =password (');
Query OK, 0 rows affected, 1 Warning (0.00 sec)
mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)
Mysql> exit
Bye
Re-login test:
[Email protected] ~]#/etc/init.d/mysqld restart
Shutting down MySQL. success!
Starting MySQL. success!
[[email protected] ~]# MySQL
Mysql>
Learn note-centos7.4 under MySQL compilation installation