您的位置:首页 > 数据库 > MySQL

MySQL单实例或多实例启动脚本

2016-09-12 18:43 363 查看
1. [root@zyl scripts]# cat mysqld01.sh 2. #!/bin/bash3. 4. . /etc/init.d/functions5. user=root6. pass=8888887. path="/application/mysql/bin"8. function usage(){9. echo "Usage:$0{start|stop|restart|}"10. exit111. }12. [ $# -ne 1 ]&& usage13. function start_db(){14. $path/mysqld_safe--user=$user >/dev/null &15. if [ $? -eq 0 ];then16. action"starting MySQL..." /bin/true17. else18. action"start MySQL..." /bin/false19. fi20. } 21. function stop_db(){22. $path/mysqladmin-u$user -p$pass shutdown &>/dev/null 23. if [ $? -eq 0 ];then 24. action"stoping MySQL..." /bin/true25. else26. action"stop MySQL..." /bin/false27. fi28. } 29. if [ "$1" == "start"];then30. start_db31. elif [ "$1" == "stop"];then32. stop_db33. elif [ "$1" == "restart"];then34. stop_db35. sleep336. start_db37. else38. usage39. fi
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MySQL Shell