Directory
- 1 Preparing the compilation environment
- 2 download unzip MySQL
- 3 compiling MySQL
- 4 modifying file permissions to build a database
- 5 starting MySQL
- 6. Configure users
- 7. Configure the Firewall
The MySQL version that comes with CentOS is very old, the performance is not the new version, and the 5.6 version has done a lot of optimizations for performance, such as subqueries. Sub-query before 5.6 version is almost a chicken, the speed is very slow. Aside from the difference in performance, do technology, life is not to toss it? Come on, toss it.
Preparing the Environment for compilation
1 Yum Install Make gcc-c++ cmake bison-devel gcc2 autoconf automake zlib* fiex* libxml* libmcrypt* libtool-ltdl-devel*
Download unzip MySQL
wget http://dev.mysql.com/get/downloads/mysql-5.6/mysql-5.6.16.tar.gztar - XVZF mysql-5.6. . Tar . gzcd MySQL-5.6. -
compiling MySQL
Configuring MySQL Installation Information
1 CMake2-dcmake_install_prefix=/usr/local/MySQL3-dmysql_datadir=/data/mysql/Data4-dsysconfdir=/etc5-dwith_myisam_storage_engine=1 6-dwith_innobase_storage_engine=1 7-dwith_memory_storage_engine=1 8-dwith_readline=1 9-dmysql_unix_addr=/tmp/mysql/Mysql.sockTen-dmysql_tcp_port=3306 One-denabled_local_infile=1 A-dwith_partition_storage_engine=1 --dextra_charsets= All --ddefault_charset=UTF8 the-ddefault_collation=utf8_general_ci
CMake equivalent to the previous./configure. For more parameters please refer to http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html.
Then compile the MySQL source code
1 Make Make Install
The compilation time may be long, I compile the time about 15 minutes.
Modify file permissions to build a database
1 Groupadd MySQL 2 useradd-r-g MySQLmysql3 cd/usr/local/mysql4chown -R Mysql:mysql. 5 scripts/mysql_install_db--user=mysql--ldata=/data/mysql/data6chown - R root. 7 chown -R MySQL Data
Note: When starting the MySQL service, will be in a certain order to search my.cnf, first in the/etc directory, find will search "$basedir/my.cnf", in this case is/usr/local/mysql/ MY.CNF, this is the default location for the new MySQL configuration file!
Note: After the minimum installation of the CentOS version 6.4 operating system, there will be a my.cnf in the/etc directory, which will need to be renamed to a different name, such as:/etc/ My.cnf.bak, otherwise, the file will interfere with the correct configuration of the source installed MySQL, resulting in the inability to start.
After updating the system with Yum Update, you need to check if there is a my.cnf in the/etc directory, and if so, rename it to something else. Otherwise, MySQL will start with this configuration file, which may cause problems such as an inability to start properly.
Start MySQL
Add services, Copy service scripts to the INIT.D directory, and set boot boot
1 CP support-files/mysql.server/etc/init.d/mysql2chkconfig mysqlon3 Service MySQL start --Start MySQL
Configure users
The MySQL root user's password is empty by default and we need to set the root password.
Before setting up, we need to set the PATH environment variable to tell the system where MySQL is installed so that you can use the MySQL command directly
Modify the/etc/profile file to add at the end of the file
1 path=/usr/local/mysql/bin: $PATH2 export PATH
Exit/etc/profile, run the following command, and let the configuration take effect immediately
1 source/etc/profile
Now, we can enter the MySQL environment directly in the terminal by entering ' MySQL '
Execute the following command to modify the root password
1 mysql-uroot 2 mysql> SET PASSWORD = PASSWORD ('123456' );
To set the root user to have remote access, perform
1 ' Root '@'172.16.%'password' with GRANT option;--' Password ' is user-defined
Configuring firewalls
Firewall 3306 port is not enabled by default, to remote access, you need to open this port
Open/etc/sysconfig/iptables
Under "-A input–m State--state new–m tcp–p–dport 22–j ACCEPT", add:
1 3306 -j ACCEPT
Then save and close the file, run the following command in the terminal and refresh the firewall configuration:
1 Service iptables restart
So Far,mysql has been installed.
Articles from http://www.chenyudong.com/archives/building-mysql-5-6-from-source.html and http://www.cnblogs.com/xiongpq/p/3384681.html
Build and install MySQL5.6 under CentOS