1、安装环境

2、安装依赖

3、创建用户

4、编译安装

5、数据库初始化

6、修改环境变量


1、 安装环境

CentOS Linux release 7.2.1511 

安装目录/application/

安装方式:编译安装

安装mysql版本:mysql-5.7.9

2、 安装依赖

1)安装依赖及工具

yum -y install make gcc-c++ cmake bison-devel  ncurses-devel perl vim wget

2)安装boost

下载安装boost:

wget -c https://jaist.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz -P /toolsmkdir -p /usr/local/boostcp /tools/boost_1_59_0.tar.gz /usr/local/boost

3、创建用户

useradd  mysql -s  /sbin/nologin -M

4、安装mysql

下载mysql

wget  -c https://downloads.mysql.com/archives/get/file/mysql-5.7.9.tar.gz -P /tools cd /tools/ && tar -xf mysql-5.7.9.tar.gzcd mysql-5.7.9

编译安装

cmake -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.9 -DMYSQL_DATADIR=/application/mysql-5.7.9/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/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 -DWITH_BOOST=/usr/local/boostmake && make install chown -R mysql:mysql /application/mysql-5.7.9   #修改权属

5、数据库初始化

cp support-files/my-default.cnf  /etc/my.cnf        #修改配置文件cat>/etc/my.cnf<<EOF# For advice on how to change settings please see# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the# *** default location during install, and will be replaced if you# *** upgrade to a newer version of MySQL.[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 = .....# port = .....# server_id = .....# socket = .....basedir = /application/mysql-5.7.9datadir = /application/mysql-5.7.9/dataport = 3306server_id = 1socket = /tmp/mysql.sock# 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 = 2MEOFcd /application/mysql-5.7.9bin/mysqld --initialize --user=mysql --datadir=/application/mysql-5.7.9/data         #初始化support-files/mysql.server start                                                     #启动mysqlln -s /application/mysql-5.7.9/ /application/mysql

6、修改环境变量

echo '#mysql'>>/etc/profileecho 'PATH=${PATH}:/application/mysql/bin'>>/etc/profilesource /etc/profile