Features Overview:
Since MySQL installed under CentOS 6.7 is version 5.1 and does not meet the requirements, it is often necessary to compile and install the MySQL service.
First, install MySQL
1. Installation Prerequisites
1) Install the package on which the MySQL code is compiled
[Email protected] ~]# yum-y install make gcc-c++ cmake bison-devel ncurses-devel
2) Download mysql-5.5.20 source Package
[[Email protected] ~] #http://mirrors.sohu.com/mysql/mysql-5.6/mysql-5.6.31.tar.gz
3) Create MySQL user and MySQL data directory
[[Email protected] ~] #useradd-r-s/sbin/nologin MySQL
[[Email protected] ~] #mkdir-P/blog/data
[[Email protected] ~] #chown-R mysql.mysql/blog/data
2. Compile and install MySQL
[[Email protected] ~] #tar XF mysql-5.6.31.tar.gz
[[Email protected] ~] #cd mysql-5.6.31
[Email protected] mysql-5.6.31]# cmake \-dcmake_install_prefix=/usr/local/mysql \-dmysql_datadir=/blog/data \-DSYS CONFDIR=/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
[[email protected] mysql-5.6.31] #make && make install
(see MySQL website for common compilation parameters: http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html)
Second, configure the MySQL service
[[Email protected] ~] #chown-R mysql:mysql/usr/local/mysql
1) Initialize the configuration
[[email protected] mysql-5.6.31] #cd/usr/local/mysql
[[email protected] MySQL] #scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/blog/data--user=mysql
160902 16:56:14 [Note]/usr/local/mysq//bin/mysqld (mysqld 5.5.50) starting as Process 18740 ...
Ok
Filling Help Tables ...
160902 16:56:14 [Note]/usr/local/mysq//bin/mysqld (mysqld 5.5.50) starting as Process 18748 ...
Ok
(see these two ok, then go to the Cd/blog/data directory to see if there is a database inside)
2) Configure MySQL startup service
[email protected] mysq]# CP support-files/mysql.server/etc/init.d/mysqld
[[email protected] MySQL] #chmod +x/etc/init.d/mysqld
3) configuration/etc/my.cnf
[Email protected] mysql]# VIM/ETC/MY.CNF
[Email protected] mysql]# VIM/ETC/MY.CNF
[Mysqld]
Datadir=/blog/data
Socket=/tmp/mysql.sock
User=mysql
Innodb_file_per_table=1
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0
[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
[[email protected] MySQL] #ln-sv/tmp/mysql.sock/var/lib/mysql/mysql.sock
[[email protected] MySQL] #service mysqld start
4) Configure the path variable and create a MySQL password
[Email protected] mysq]# vim/etc/profile.d/mysql.sh
Path=/usr/local/mysq/bin: $PATH
Export PATH
[[email protected] MySQL] #source/etc/profile.d/mysql.sh
Modify the root password of the MySQL server
[[email protected] MySQL] #mysql-uroot
mysql> SET PASSWORD = PASSWORD (' 123456 ');
Mysql> GRANT All privileges on * * to ' root ' @ ' 10.2.18.% ' identified by ' Lsf123' with GRANT OPTION;
5) Configure Iptables Firewall service, release 3306 Port
[[email protected] MySQL] #iptables-i input-m State--state new-m tcp-p tcp-dport 3306-j ACCEPT
[[email protected] MySQL] #service iptables save
[[email protected] MySQL] #service iptables restart
Compiling the installation on the CentOS6.7 operating system mysql-5.6.31