mysql启动脚本

#!/bin/sh
#Mysql start|stop|restart
#Created by zenglong
#20130325
mysql_port=$2
mysql_username="root"
mysql_password="mysql"
mysql_port="3306"
function_start_mysql()
{
   printf "Starting MySQL......\n"
   /usr/local/mysql/bin/mysqld_safe  2>&1 > /dev/null &
}
function_stop_mysql()
{
   printf "Stoping MySQL......\n"
   /usr/local/mysql/bin/mysqladmin -u${mysql_username} -p${mysql_password}  shutdown
}
function_restart_mysql()
{
   printf "Restarting MySQL......\n"
   function_stop_mysql
   function_start_mysql
}
function_open_mysql()
{
   /usr/local/mysql/bin/mysql -u${mysql_username} -p${mysql_password}
}
if [ "$1" = "start" ]; then
   function_start_mysql
elif [ "$1" = "stop" ]; then
   function_stop_mysql
elif [ "$1" = "restart" ]; then
   function_restart_mysql
elif [ "$1" = "open" ]; then
   function_open_mysql
else
   printf "Usage: mysql.sh {start|stop|restart}|{port}\n"
fi
############################################################
#Usage:chmod +x mysq.sh
#mysql.sh start 3306mysql.sh stop 3306mysql.sh restart mysql.sh open

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf 2>&1 > /dev/null &

相关推荐