What Is MySQL Default Port Number?

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM

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.

TCP 3306

The default port for the MySQL service is TCP 3306. This port can be also used for MariaDB database server.

List with netstat Command

We can use netstat command in order to list MySQL/MariaDB database server port number.

List with netstat Command
List with netstat Command

We can see from output that port 3306 port is listening on the local interface 127.0.0.1

For MariaDB change grep mysql with grep mariadb

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.

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.

OR we can scan all ports of the given host.

Find with SQL Query

Configuration parameter of the MySQL or MariaDB Database server is stored in the variables too. We can use some SQL inorder to print the port information from environment variables like below.

LEARN MORE  Tcp and Udp Port List, Names and Usage Frequency

Find with SQL Query
Find with SQL Query

We can see that port variable is current set to  3306.

 

 

RSS
FACEBOOK
FACEBOOK
PINTEREST
PINTEREST
LINKEDIN
INSTAGRAM