一、Mysql-5.6.25 安装
1.必要软件:
yum -y install gcc gcc-c++ autoconf automake bison ncurses-devel libtool-ltdl-devel* cmake make
2.编译安装
##########################
可选安装:cmake11.2.1版本
[root@localhost src]# wget http://www.NaNake.org/files/v2.8/cmake-2.8.12.1.tar.gz
[root@localhost src]# tar -zvxf cmake-2.8.12.1.tar.gz
[root@localhost src]# cd cmake-2.8.12.1
[root@localhost cmake-2.8.12.1]# ./bootstrap
[root@localhost cmake-2.8.12.1]# make&&make install
[root@localhost cmake-2.8.12.1]# cmake --help |head -n1
cmake version 2.8.12.1
2.1 开始准备环境和编译安装
/usr/sbin/groupadd mysql
/usr/sbin/useradd -s /sbin/nologin -M -g mysql mysql
mkdir /data/mysql/data -p
mkdir /usr/local/mysql -p
wget -nv -q -O /usr/local/src/mysql-5.6.25.tar.gz http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.25.tar.gz
cd /usr/local/src/
tar -zvxf mysql-5.6.25.tar.gz
##########################
有哪些存储引擎的支持可以看一个目录
[root@localhost storage]# ls
archive csv federated innobase myisammrg perfschema
blackhole example heap myisam ndb
[root@localhost storage]# pwd
/usr/local/src/mysql-5.6.10/storage
开始编译咯!!
cd mysql-5.6.25
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql/data/ \
-DSYSCONFDIR=/etc \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=complex \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EMBEDDED_SERVER=1
make -j 4
make install
参数配置部分解释:
其实5.6版本可以所有的关于引擎的参数不填写,因为默认是全部给安装的
而5.5则不同
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
上面三个是必须要自己填写的否则的话只能编译出6个引擎;
# /* -DWITH_READLINE=1 # 快捷键功能
# /* -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysqld.sock # 连接数据库socket路径
# /* -DENABLED_LOCAL_INFILE=1 # 允许从本地导入数据
make -j 4 # 4代表cpunum,如果多核可以多加几个
2.2 设置权限:
chown mysql /data/mysql -R
chown mysql /usr/local/mysql -R
2.3 初始化数据库和设置启动进程脚本:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data --basedir=/usr/local/mysql
ulimit -s unlimited
cd /usr/local/mysql/support-files/
cp mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
2.4 设置环境变量:
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile
source /etc/profile
2.5 设置配置文件:
cd /usr/local/mysql/support-files/
cp -f my-default.cnf /etc/my.cnf
[root@localhost support-files]# cat >> /etc/my.cnf <<EOF
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
datadir=/data/mysql/data
basedir=/usr/local/mysql
socket=/tmp/mysql.sock
log-bin=mysql-bin
expire_logs_days=10
binlog_format=mixed
table_definition_cache=10000
max_connections=1000
key_buffer_size=256M
tmp_table_size=64M
read_buffer_size=4M
read_rnd_buffer_size=16M
sort_buffer_size=64M
thread_cache_size=80
wait_timeout=7200
thread_concurrency = 8
innodb_buffer_pool_size=1024M
innodb_sort_buffer_size=4M
innodb_thread_concurrency=4
innodb_flush_log_at_trx_commit = 2
log-output=NONE
general-log=1
general_log_file=/usr/local/mysql/general.log
slow-query-log=1
slow_query_log_file=/usr/local/mysql/mysql-slow.log
long_query_time=10
log_queries_not_using_indexes=1
[mysqld_safe]
log-error=/usr/local/mysql/mysqlerr.log
pid-file=/usr/local/mysql/mysqld.pid
mysqld=mysqld
EOF
# chown mysql.mysql /etc/my.cnf
# 将安装目录属主改为mysql (上面更改,到这里又变成root属主了,所以可以选择更改为mysql )
# chkconfig --add mysqld
# chkconfig mysqld on
# chkconfig --list |grep mysql --234必须为on
# service mysqld start