Skip to content

Instantly share code, notes, and snippets.

@faizal2007
Created October 18, 2016 10:49
Show Gist options
  • Save faizal2007/1a03a5c5fa318f9e0385f35472d6137e to your computer and use it in GitHub Desktop.
Save faizal2007/1a03a5c5fa318f9e0385f35472d6137e to your computer and use it in GitHub Desktop.
Check mysql remote port access
#!/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