Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130290
  • 博文数量: 32
  • 博客积分: 2547
  • 博客等级: 少校
  • 技术积分: 405
  • 用 户 组: 普通用户
  • 注册时间: 2007-11-15 19:58
文章分类

全部博文(32)

文章存档

2009年(20)

2008年(12)

我的朋友

分类: LINUX

2008-12-12 12:26:06

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) |
0

上一篇:增加环境变量

下一篇:Crontab实例

给主人留下些什么吧!~~