How to Check the Connection to MySQL DB Server

I would share the way to check the connection to MySQL database server. We can use the telnet or nc command to connect to port 3306. This would be very useful when we do the troubleshooting or to test the connectivity between the application server and the database server. Sample outputs will show succeeded or connected as below :

Host A = 192.168.0.5
Host B = 192.168.0.6

1. Test connectivity using nc command :

[root@192.168.0.5 ~]# nc -z -w1 192.168.0.6 3306
Connection to 192.168.0.6 3306 port [tcp/mysql] succeeded!

2. Test connectivity using telnet command :

[root@192.168.0.5 ~]# echo X | telnet -e X 192.168.0.6 3306
Telnet escape character is 'X'.
Trying 192.168.0.6...
Connected to 192.168.0.6.
Escape character is 'X'.

telnet> Connection closed.
Leave a Reply

Your email address will not be published. Required fields are marked *

SiteGround.com

A world leading hosting company that provides fully-managed innovative and secure solutions, suitable for hosting small to medium-sized websites

Built on the best available technologies combined with Google Cloud for strong redundancy and application availability. Backed by skilled experts to address web security threats, a devops team to create advanced custom security solutions, and 24/7 sysadmins to watch over the platform. This powerful, hands-on approach makes your sites faster, safer, and easier to manage. Starting from only $3.95/mo.

TRY FREE

* up to 30 days money back guarantee