CentOS 6.8 下安装mysql-5.6
安装环境:
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用户
[[email protected] ~]# groupadd -g 306 mysql
[[email protected] ~]# useradd -g 306 -u 306 -s/sbin/nologin -M mysql
添加数据目录和软件安装目录
[[email protected] ~]# mkdir /data/mysql –pv
[[email protected] ~]#mkdir /root/software
[[email protected] ~]# mkdir /usr/local/mysql
[[email protected] ~]# chown -R mysql.mysql /usr/local/mysql
编译并安装
[[email protected] ~]# cd /root/software
[[email protected] software]# wget
[[email protected] software]# tar xf percona-server-5.6.29-76.2.tar.gz
[[email protected] 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
编译、安装
[[email protected] percona-server-5.6.29-76.2]# make
[[email protected] percona-server-5.6.29-76.2]# make install
修改属组、属主
[[email protected] local]# chown -R mysql.mysql /usr/local/mysql
[[email protected] ~]# chown -R mysql.mysql /data/mysql
初始化系统数据库
[[email protected] mysql]#
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql
--basedir=/usr/local/mysql
修改配置文件
[[email protected] ~]# 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服务
[email protected] ~]# cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
[[email protected] ~]# chmod +x /etc/rc.d/init.d/mysqld
[[email protected] ~]# chkconfig --add mysqld
[[email protected] ~]# chkconfig mysqld on
[[email protected] ~]# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf
[[email protected] ~]# ln -sv /usr/local/mysql/include /usr/include/mysqld
设置mysql环境变量
[[email protected] ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh
[[email protected] ~]# source /etc/profile.d/mysql.sh
配置帮助文档
[[email protected] ~]# vim /etc/man.config
MANPATH /usr/local/mysql/man
[[email protected] ~]# service mysqld start
Starting MySQL (Percona Server). [ OK ]
现象
[[email protected] local]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'
解决办法
[email protected] local]# vim /etc/my.cnf
[client]
socket=/data/mysql/mysql.sock
原文地址:http://blog.51cto.com/437549/2108349