启动脚本:start.sh

#!/bin/bash

for port in {3390..3396}

do

(/export/servers/mysql/bin/mysqld_safe --defaults-file=/export/servers/mysql/etc/my$port.cnf ) &

done


关闭脚本:stop.sh

#!/bin/bash

for port in {3390..3396}

do

(/export/servers/mysql/bin/mysqladmin -uroot -p -S /export/data/mysql/tmp/mysql$port.sock shutdown) &

done

 

 

 

在测试环境中,在一台服务器上创建多个实例,在每个实例中一个一个删库比较麻烦,因此用下面脚本,可以直接删除所有库,除了系统库以外:

#!/bin/bash

mysql=/export/servers/mysql/bin/mysql

for i in {3361..3362}
do
for j in $($mysql -uroot -p123456 -S /export/data/mysql/tmp/mysql$i.sock -e "show databases" |egrep -v "information_schema|mysql|test|performance_schema|Database")
do
$mysql -uroot -p123456 -S /export/data/mysql/tmp/mysql$i.sock -e "drop database \`$j\`"
done
done

 

 

 

 

安装多实例MySQL数据库,安装完成后默认无密码,一次性给所有实例的root账户创建密码:


#!/bin/bash

for i in {3361..3363}

do

/export/servers/mysql/bin/mysql -uroot -S /export/data/mysql/tmp/mysql$i.sock <<EOF

use mysql;

update user set password=password('123456') where user='root';

flush privileges;

EOF

done

 

 

[root@yoon export]# vi gunzip.sh

!/bin/bash

path=/export/backup ----备份文件目录路径


for i in `ls ${path}/*`

do

/bin/gunzip $i

done


[root@yoon export]# chmod +x gunzip.sh

[root@yoon export]# sh gunzip.sh




==========================================


#!/bin/bash
#dir=/export/data/mysql/dumps/`date +%F -d yesterday`
dir=/export/data/mysql/dumps/`date +%F`
gunzip=$(find $dir -name "*.sql.gz")
for i in $gunzip
do
(gunzip $i) &
done