安装环境:
CentOS release 6.8 (Final)
percona-server-5.6.29-76.2
安装依赖库和工具
yum -y install gcc gcc-c++ libgcrypt openssl openssl098e openssl-devel ncurses ncurses-devel make cmake g++ bison ncurses-libs libaio unzip readline-devel
yum -y install wget iproute iotop mtr perf dstat iftop
添加mysql用户
[root@Paul ~]# groupadd -g 306 mysql
[root@Paul ~]# useradd -g 306 -u 306 -s/sbin/nologin -M mysql
添加数据目录和软件安装目录
[root@Paul ~]# mkdir /data/mysql –pv
[root@Paul ~]#mkdir /root/software
[root@Paul ~]# mkdir /usr/local/mysql
[root@Paul ~]# chown -R mysql.mysql /usr/local/mysql
编译并安装
[root@Paul ~]# cd /root/software
[root@Paul software]# wget
[root@Paul software]# tar xf percona-server-5.6.29-76.2.tar.gz
[root@Paul software]# cd percona-server-5.6.29-76.2
配置mysql预编译参数
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql #软件安装目录
-DMYSQL_DATADIR=/data/mysql \ #数据目录
-DSYSCONFDIR=/etc/my.cnf\ #配置文件
-DMYSQL_TCP_PORT=3306 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 -DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci -DENABLE_DTRACE=0\
-DWITH_EXTRA_CHARSETS=all
编译、安装
[root@Paul percona-server-5.6.29-76.2]# make
[root@Paul percona-server-5.6.29-76.2]# make install
修改属组、属主
[root@Paul local]# chown -R mysql.mysql /usr/local/mysql
[root@Paul ~]# chown -R mysql.mysql /data/mysql
初始化系统数据库
[root@Paul mysql]#
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql
--basedir=/usr/local/mysql
修改配置文件
[root@Paul ~]# vim /etc/my.cnf
[mysqld]
datadir=/data/mysql #数据目录
user=mysql
log-bin=mysql-bin #log-bin文件存放目录
basedir = /usr/local/mysql
character_set_server = utf8 #server级别字符集
default_storage_engine = InnoDB #默认存储
innodb_buffer_pool_size = 4000M #主要作用是缓存innodb表的索引,数据,插入数据的 缓冲
explicit_defaults_for_timestamp = true #开启查询缓
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/tmp/mysql.sock
配置mysqld服务
root@Paul ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@Paul ~]# chmod +x /etc/rc.d/init.d/mysqld
[root@Paul ~]# chkconfig --add mysqld
[root@Paul ~]# chkconfig mysqld on
[root@Paul ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[root@Paul ~]# ln -sv /usr/local/mysql/include /usr/include/mysqld
设置mysql环境变量
[root@Paul ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
[root@Paul ~]# source /etc/profile.d/mysql.sh
配置帮助文档
[root@Paul ~]# vim /etc/man.config
MANPATH /usr/local/mysql/man
[root@Paul ~]# service mysqld start
Starting MySQL (Percona Server). [ OK ]
现象
[root@Paul local]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
解决办法
root@Paul local]# vim /etc/my.cnf
[client]
socket=/data/mysql/mysql.sock
原文地址:http://blog.51cto.com/437549/2108349