Centos 安装 Percona Server 代替mysql

1.可通过 yum 安装

yum install http://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm  
yum list | grep percona  
yum install Percona-Server-server-57  

2.还可通过 rpm packages 安装

wget https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-5.7.22-22/binary/redhat/7/x86_64/Percona-Server-5.7.22-22-rf62d93c-el7-x86_64-bundle.tar  
tar xvf Percona-Server-5.7.22-22-rf62d93c-el7-x86_64-bundle.tar  
ls *.rpm  
rpm -ivh Percona-Server-server-57-5.7.22-22.1.el7.x86_64.rpm \  
Percona-Server-client-57-5.7.22-22.1.el7.x86_64.rpm \  
Percona-Server-shared-57-5.7.22-22.1.el7.x86_64.rpm \  
Percona-Server-shared-compat-57-5.7.22-22.1.el7.x86_64.rpm  

rpm -ivh *.rpm 可通过该命令,安装全部的包,包括 debugging,testing,etc

3.配置文件

数据文件默认在:/var/lib/mysql/ 配置文件默认在:/etc/my.cnf

4.启动、停止服务

CentOS 6:

service mysqld start  
service mysqld restart  
## ...

CentOS 7:

systemctl start mysqld.service  
systemctl restart mysqld.service  
## ...
## 添加开机启动
systemctl enable mysqld.service  

5.卸载

# 停止服务
service mysqld stop  
##or
systemctl stop mysqld.service  
# 删除包
yum remove Percona-Server*  
# 删除数据目录和配置文件
rm -rf /var/lib/mysql  
rm -f /etc/my.cnf  

6.修改 Percona 默认密码

修改方法与 mysql 5.7 配置一样,运行mysql_secure_installation命令,根据提示操作即可。
默认密码在错误日志中,错误日志位置可以在/etc/my.cnf文件中找到(log-error),一般是/var/log/mysqld.log,可以通过以下命令快捷找到:

cat /var/log/mysqld.log | grep "temporary password"