mysql便於管理的幾個shell指令碼

kisslfcr發表於2017-09-18
[mysql@clark scripts]$ ls
mysql_db_shutdown.sh  mysql_db_startup.sh  mysql_env.ini  mysqlplus.sh
[mysql@clark scripts]$ more mysql_db_shutdown.sh 
#/bin/sh
#Created by clark 20170918


source /data/mysqldata/scripts/mysql_env.ini


echo "Shutdown MySQL Service: localhost_"${HOST_PORT}
/usr/local/mysql/bin/mysqladmin -u${MYSQL_USER} -p${MYSQL_PASS} -S /data/mysqldata/${HOST_PORT}/mysql.sock shutdown
[mysql@clark scripts]$ 
[mysql@clark scripts]$ 
[mysql@clark scripts]$ more mysql_db_startup.sh 
#/bin/sh
#Created by clark 20170918


source /data/mysqldata/scripts/mysql_env.ini


echo "Startup MySQL Service: localhost_"${HOST_PORT}
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysqldata/${HOST_PORT}/my.cnf &
[mysql@clark scripts]$ 
[mysql@clark scripts]$ 
[mysql@clark scripts]$ more mysql_env.ini 
#set env
MYSQL_USER=system
MYSQL_PASS='welcome123'


#check parameter
if [ $# -ne 1 ]
then 
        HOST_PORT=3306
else
        HOST_PORT=$1
fi
[mysql@clark scripts]$ 
[mysql@clark scripts]$ more mysqlplus.sh 
#/bin/sh
#Created by clark 20170918


source /data/mysqldata/scripts/mysql_env.ini


echo "Login MySQL Service: localhost_"${HOST_PORT}
/usr/local/mysql/bin/mysql -u${MYSQL_USER} -p${MYSQL_PASS} -S /data/mysqldata/${HOST_PORT}/mysql.sock

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2145120/,如需轉載,請註明出處,否則將追究法律責任。

相關文章