Code:
#!/bin/sh
#Mysql start|stop|restart
#Created by ritto
#20081120
mysql_port=$2
mysql_username="root"
mysql_password="123456"
mysql_port="3306"
function_start_mysql()
{
printf "Starting MySQL......\n"
/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf 2>&1 > /dev/null &
}
function_stop_mysql()
{
printf "Stoping MySQL......\n"
/usr/local/mysql/bin/mysqladmin -u${mysql_username} -p${mysql_password} -S /tmp/mysql.sock 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}\n"
fi
|
############################################################
Usage:
chmod +x mysq.sh
mysql.sh start 3306
mysql.sh stop 3306
mysql.sh restart
mysql.sh open
阅读(1480) | 评论(0) | 转发(0) |