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 =
Host B =

1. Test connectivity using nc command :

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

2. Test connectivity using telnet command :

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

telnet> Connection closed.

One comment on “How to Check the Connection to MySQL DB Server

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>