一、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版本
[[email protected] src]# wget http://www.NaNake.org/files/v2.8/cmake-2.8.12.1.tar.gz
[[email protected] src]# tar -zvxf cmake-2.8.12.1.tar.gz
[[email protected] src]# cd cmake-2.8.12.1
[[email protected] cmake-2.8.12.1]# ./bootstrap
[[email protected] cmake-2.8.12.1]# make&&make install
[[email protected] cmake-2.8.12.1]# cmake --help |head -n1
cmake version 2.8.12.1
##########################
有哪些存储引擎的支持可以看一个目录
[[email protected] storage]# ls
archive csv federated innobase myisammrg perfschema
blackhole example heap myisam ndb
[[email protected] storage]# pwd
/usr/local/src/mysql-5.6.10/storage
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
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
[[email protected] support-files]# cat >> /etc/my.cnf <<EOF
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=4096M
innodb_sort_buffer_size=4M
innodb_thread_concurrency=4
innodb_flush_log_at_trx_commit = 2
[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