Created
October 18, 2016 10:49
-
-
Save faizal2007/1a03a5c5fa318f9e0385f35472d6137e to your computer and use it in GitHub Desktop.
Check mysql remote port access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SERVER=db2 | |
PORT=3306 | |
(echo > /dev/tcp/$SERVER/$PORT) | |
if [ "$?" -ne 0 ]; then | |
echo "Connection to $SERVER on port $PORT failed" | |
/etc/init.d/mysql stop | |
/etc/init.d/mysql bootstrap | |
exit 1 | |
else | |
echo "Connection to $SERVER on port $PORT succeeded" | |
/etc/init.d/mysql start | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment