1. [root@zyl scripts]# cat mysqld01.sh
2. #!/bin/bash
3.
4. . /etc/init.d/functions
5. user=root
6. pass=888888
7. path="/application/mysql/bin"
8. function usage(){
9. echo "Usage:$0{start|stop|restart|}"
10. exit1
11. }
12. [ $# -ne 1 ]&& usage
13. function start_db(){
14. $path/mysqld_safe--user=$user >/dev/null &
15. if [ $? -eq 0 ];then
16. action"starting MySQL..." /bin/true
17. else
18. action"start MySQL..." /bin/false
19. fi
20. }
21. function stop_db(){
22. $path/mysqladmin-u$user -p$pass shutdown &>/dev/null
23. if [ $? -eq 0 ];then
24. action"stoping MySQL..." /bin/true
25. else
26. action"stop MySQL..." /bin/false
27. fi
28. }
29. if [ "$1" == "start"];then
30. start_db
31. elif [ "$1" == "stop"];then
32. stop_db
33. elif [ "$1" == "restart"];then
34. stop_db
35. sleep3
36. start_db
37. else
38. usage
39. fi