首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql 起动关闭shell脚本

2013-03-27 
mysql 启动关闭shell脚本#!/bin/shmysql_port3306mysql_usernamerootmysql_passwordfunction_start

mysql 启动关闭shell脚本

#!/bin/shmysql_port=3306mysql_username="root"mysql_password=""function_start_mysql(){printf "Starting MySQL...\n"/bin/sh /data/mysql/bin/mysqld_safe --defaults-file=/data/mysql/${mysql_port}/my.cnf 2>&1 > /dev/null &}function_stop_mysql(){printf "Stoping MySQL...\n"/data/mysql/bin/mysqladmin -u ${mysql_username} -p${mysql_password} -S /data/mysql/mysql.sock shutdown}function_restart_mysql(){printf "Restarting MySQL...\n"function_stop_mysqlsleep 5function_start_mysql}function_kill_mysql(){kill -9 $(ps -ef | grep 'bin/mysqld_safe' | grep ${mysql_port}| awk '{printf $2}')kill -9 $(ps -ef | grep 'libexec/mysqld' | grep ${mysql_port}| awk '{printf $2}')}if [ "$1" = "start" ]; thenfunction_start_mysqlelif [ "$1" = "stop" ]; thenfunction_stop_mysqlelif [ "$1" = "restart" ]; thenfunction_restart_mysqlelif [ "$1" = "kill" ]; thenfunction_kill_mysqlelseprintf "Usage: /data/mysql/${mysql_port}/mysql{start|stop|restart|kill}\n"fi

热点排行