Compile and install MySQL5.6.23 on CentOS7
1. Download source code
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.23.tar.gz
2. Extract
tar zxvf mysql-5.6.23.tar.gz
3. install necessary packages
sudo yum install cmake gcc-c++ ncurses-devel perl-Data-Dumper
4. Go to the mysql source code directory and generate makefile
cmake .
5. Compile
make
6. Install
sudo make install
Mysql will be installed in the/usr/local/mysql path.
7. Add mysql users and groups
sudo groupadd mysqlsudo useradd -r -g mysql mysql
8. modify directory and file permissions and install the default database
cd /usr/local/mysqlsudo chown -R mysql .sudo chgrp -R mysql .sudo scripts/mysql_install_db --user=mysql
sudo chown -R root .
sudo chown -R mysql data
So far, mysql can start and run.
9. Start mysql
CentOS7 comes with MariaDB support. By default, the my. cnf file in/etc interferes with mysql running. You need to delete it first.
cd /etcsudo rm -fr my.cnf my.cnf.d
And then recreate the my. cnf file under/etc. The content is as follows:
# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html[mysqld]# Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M# Remove leading # to turn on a very important data integrity option: logging# changes to the binary log between backups.# log_bin# These are commonly set, remove the # and set as required.# basedir = .....# datadir = /data/mysql/data# port = .....# server_id = .....# socket = .....# Remove leading # to set options mainly useful for reporting servers.# The server defaults are 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 max_connection = 10000sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES #binary log log-bin = mysql-binbinlog_format = mixedexpire_logs_day = 30#slow query log slow_query_log = 1slow_query_log_file = /var/log/mysql/slow.loglong_query_time = 3log-queries-not-using-indexeslog-slow-admin-statements
Now you can start mysql.
sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &
CentOS7 cannot use the service to control the mysql service, and mysql installed in the source code does not provide the Systemd control script.
Then, edit the/etc/rc. d/rc. local file and add the mysql startup command.
/usr/local/mysql/bin/mysqld_safe --user=mysql &
Then add executable permissions to/etc/rc. d/rc. local.
sudo chmod a+x /etc/rc.d/rc.local
9. Modify the root password
/usr/loca/mysql/bin/mysql -urootuse mysql;UPDATE user SET password = PASSWORD('test2015') WHERE user = 'root';
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY 'stcm2015';
FLUSH PRIVILEGES;
So far, the installation is complete, and a mysql can be used.