一、删除percona server

1.关闭mysqld  service mysqld stop,再删除 rm -rf /etc/my.cnf

2.删除rm -rf /usr/local/Percona-Server-5.5.33-rel31.1-566.Linux.x86_64文件夹

3.删除软链接 rm -rf /usr/local/mysql

4.chkconfig --del mysqld

  删除rm -rf /etc/init.d/mysqld

5.删除mysql用户,和组 /usr/sbin/userdel mysql

6.去掉环境变量

 

 

 

[root@tthost3 ~]# cat uninstall.sh

#!/bin/bash

/sbin/service mysqld stop &&

/bin/rm -rf /etc/my.cnf &&

/bin/rm -rf /usr/local/Percona-Server-5.5.33-rel31.1-566.Linux.x86_64 &&

/bin/rm -rf /usr/local/mysql &&

/sbin/chkconfig --del mysqld &&

/bin/rm -rf /etc/init.d/mysqld &&

/usr/sbin/userdel mysql

 

 

 

二、自动安装

说明:

1.将二进制percona文件:Percona-Server-5.5.33-rel31.1-566.Linux.x86_64.tar.gz拷贝到 /usr/local目录中

2.基本的目录(percona解压文件软连接到/usr/local/mysql):

MYSQL_DIR="/usr/local"

DATA_DIR="/usr/local/mysql/data"

BASE_DIR="/usr/local/mysql"

3.将脚本拷贝到/root目录下,赋执行权限直接执行就好了

4.需要增加判断,是否已经安装有mysql了,安装过就直接退出了

 

 

 

 

[root@tthost3 ~]# cat mysqinstall.sh

#!/bin/bash

MYSQL_DIR="/usr/local"

DATA_DIR="/usr/local/mysql/data"

BASE_DIR="/usr/local/mysql"

 

 

echo "-------checking mysql ENV now! please wait-------"

username=`cat /etc/passwd|grep mysql|cut -c 1-5`

          if [[ $username == "mysql" ]];then   

           echo "user check,mysql user already have,can not install mysql!!"

else

echo "please input mysql version:"

read VERSION

echo  "your mysql version is Percona-Server-$VERSION-rel31.1-566.Linux.x86_64.tar.gz"

if [ -e "$MYSQL_DIR/Percona-Server-$VERSION-rel31.1-566.Linux.x86_64.tar.gz" ]

then

echo "Please waitting"

sleep 3

/usr/sbin/groupadd mysql &&

/usr/sbin/useradd -r -g mysql mysql &&

tar zxvf $MYSQL_DIR/Percona-Server-$VERSION-rel31.1-566.Linux.x86_64.tar.gz -C $MYSQL_DIR/ &&

cd $MYSQL_DIR/Percona-Server-$VERSION-rel31.1-566.Linux.x86_64 &&

echo "PATH=$PATH:$HOME/bin:/usr/local/mysql/bin" >> /root/.bash_profile && source /root/.bash_profile

ln -s $MYSQL_DIR/Percona-Server-$VERSION-rel31.1-566.Linux.x86_64 $MYSQL_DIR/mysql &&

cd $MYSQL_DIR/mysql &&

/bin/chown -R mysql . &&

/bin/chgrp -R mysql . &&

sh /usr/local/mysql/scripts/mysql_install_db --user=mysql

/bin/chown -R root . &&

/bin/chown -R mysql data

/bin/cp $BASE_DIR/support-files/my-medium.cnf /etc/my.cnf

/bin/cp $BASE_DIR/support-files/mysql.server /etc/init.d/mysqld

/sbin/chkconfig --add mysqld

/sbin/service mysqld start

else

echo "Your input mysql version  is not in $MYSQL_DIR"

fi

fi