Advertisement
Guest User

Untitled

a guest
Aug 1st, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # LICENSE: MIT
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to
  7. # deal in the Software without restriction, including without limitation
  8. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. # and/or sell copies of the Software, and to permit persons to whom the
  10. # Software is furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21.  
  22.  
  23. HOST="127.0.0.1"
  24. PORT="3306"
  25. USER="username"
  26. PASS="password"
  27.  
  28. SUCCESS=0
  29. ERROR=2
  30.  
  31. ERROR_MSG=`/usr/bin/mysql --host=${HOST} --port=${PORT} --user=${USER} --password=${PASS} -e "show databases;" 2>/dev/null`
  32.  
  33. if [ "${ERROR_MSG}" != "" ]; then
  34. echo "Successfully connected to mysql database."
  35. exit ${SUCCESS}
  36. else
  37. echo "Unable to connect to mysql database."
  38. exit ${ERROR}
  39. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement