What Is MySQL Default Port Number?
MySQL is very popular database in the opensource community. While developing applications or connecting MySQL database we need to specify the MySQL port implicitly or explicitly. In this tutorial we will learn MySQL default port number and alternative port numbers.
The default port for the MySQL service is TCP 3306.
Find From DB Config File
What if MySQL server default port is different from
3306 . We have some options. One of them is looking to the application database config file. We can get the port number from there. In this example the port number
3307 is specified explicitly.
$link = mysql_connect('poftut.com:3307', 'mysql_user', 'mysql_password');
Find By Nmap Scan
If we had no clue about the port number we can use some security network scanning tool named
nmap. We can scan popular or all port on the host and find MySQL service. Following command will scan top used 1000 ports.
$ nmap -sC -sV 192.168.1.10
OR we can scan all ports of the given host.
$ nmap -p- -sC -sV 192.168.1.10