一、安装依赖环境:
yum -y install libaio libaio-devel libtool make automake autoconf numactl numactl-devel bzip2 gcc gcc-c++ perl perl-DBI perl-ExtUtils-MakeMaker perl-devel perl-Time-HiRes perl-DBD-MySQL pcre-devel time jemalloc gperf cmake zlib-devel openssl-devel readline-devel readline glib2-devel mysql-devel qpress which netstat
wget
http://repositories.voole.com/jemalloc-4.0.4.tar.bz2
tar xjf jemalloc-4.0.4.tar.bz2
cd jemalloc-4.0.4
./autogen.sh
make && make install
echo '/usr/local/lib' >> /etc/ld.so.conf.d/local.conf
ldconfig
二、下载二进制包并部署:
cd /opt/soft
wget
http://repositories.voole.com/Percona-Server-5.7.21-20-Linux.x86_64.ssl101.tar.gz
tar zxvf Percona-Server-5.7.21-20-Linux.x86_64.ssl101.tar.gz
mv Percona-Server-5.7.21-20-Linux.x86_64.ssl101 /usr/local/mysql
三、创建mysql用户组
groupadd mysql && useradd -g mysql -M -s /sbin/nologin mysql
四、创建数据库文件my.cnf ,统一放到程序目录里
mv /etc/my.cnf /etc/my.cnf.bak
SSD固态盘:wget
http://repositories.voole.com/my57_19.cnf
-O /etc/my.cnf
SATA磁盘:wget
http://repositories.voole.com/my57_19_sata.cnf
-O /etc/my.cnf
从库:wget
http://repositories.voole.com/my_slave.cnf
-O /etc/my.cnf
主库:wget
http://repositories.voole.com/my_master.cnf
-O /etc/my.cnf
五、初始化,记得加上配置文件
/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --initialize
六、设置环境变量
echo "export PATH=/usr/local/mysql/bin:$PATH">>/etc/profile && source /etc/profile
which mysql
七、修改属主属组
chown -R mysql.mysql /opt/mysql_data
八、启动mysql5.7服务
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
chmod 755 /etc/init.d/mysql
/etc/init.d/mysql start
九、重置密码(mysql5.7和其他版本不同、初次安装会生成一个随机密码在/opt/mysql_data/logerr.err日志内)
密码在logerr.err 中会默认生成一个
set password=password('123456');
如果需要再次修改root密码
update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
十、设置访问权限
grant all on . to root@"%" identified by "mysql*()";