1.官网下载源码
https://www.mysql.com/
2.解压
tar zxvf mysql-5.7.10.tar.gz
3.安装必要的包
sudo yum install cmake gcc-c++ ncurses-devel perl-Data-Dumper
4.安装Boost
wget http://jaist.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.zip
unzip boost_1_59_0.zip
cd boost_1_59_0
./bootstrap.sh
./b2
sudo ./b2 install
5.生成makefile
cmake .
6.编译
make
7.安装
sudo make install
mysql将会安装到/usr/local/mysql路径。
8.添加mysql用户和组
sudo groupadd mysql
sudo useradd -r -g mysql mysql
9.修改目录和文件权限,安装默认数据库
cd /usr/local/
sudo chown -R mysql:mysql mysql/
bin/mysqld --initialize-insecure --user=mysql
[python] view plaincopy
bin/mysql_ssl_rsa_setup
sudo chown -R root .
sudo chown -R mysql data
至此,mysql就可以启动运行了。
10.启动mysql
CentOS7自带MariaDB的支持,/etc下默认存在my.cnf文件干扰mysql运行,需要先删掉
cd /etc
sudo rm -fr my.cnf my.cnf.d
然后再/etc下重建my.cnf文件,内容如下
# 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 = 1
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.