What is the standard MySQL port?

Marc Wagner, July 12, 2021

In order to be able to con­nect to your MyS­QL data­ba­se, you need the port. The same appli­es to web­sites and online shops that you have crea­ted with Word­Press, for exam­p­le.

The stan­dard value for the MyS­QL port of your data­ba­se is: 3306. Most appli­ca­ti­ons also set this value by default.

In this artic­le, I will show you how you can find out the MyS­QL port to con­nect yours­elf or the appli­ca­ti­on of your choice to your data­ba­se.

Which port does MySQL use? #

By default, MyS­QL uses the port 3306. Howe­ver, the port may have chan­ged. On the one hand this can be used for pro­tec­tion, on the other hand it can be that the port has alre­a­dy been used by ano­ther appli­ca­ti­on.

Is the MySQL port 3306 TCP or UDP? #

The default MyS­QL port is TCP (Trans­mis­si­on Con­trol Pro­to­col).

The TCP pro­to­col is the most fre­quent­ly used pro­to­col on the Inter­net. In con­trast to the UDP pro­to­col, the data is che­cked for cor­rect­ness when sen­ding and recei­ving via the TCP pro­to­col. If parts of the trans­mis­si­on are lost, they will be sent again.

The UDP pro­to­col may be fas­ter, but does not check the trans­mis­si­on for errors. Lost data can­not be reques­ted again.

Is there a vulnerability in the MySQL port? #

In gene­ral, you should­n’t open the MyS­QL port to the out­side world. Ins­tead, it is advi­sa­ble to con­nect to the ser­ver via an SSH tun­nel and then use it to estab­lish the MyS­QL con­nec­tion.

Appli­ca­ti­ons like Hei­diS­QL or Datagrip sup­port SSH tun­nel con­nec­tions.

If you still want to allow access via the port, you should spe­ci­fy that only sel­ec­ted IP addres­ses are allo­wed to access it.

How can I find the MySQL port with SQL? #

The easie­st way to find out the port is direct­ly via SQL and your PhpMy­Ad­min Inter­face. To do this, you first have to log in and then open the SQL con­so­le.

mysql port via sql statement
MyS­QL Port via SQL.

In the input field below, you can now insert the fol­lo­wing SQL state­ment to dis­play the port of your data­ba­se:

SHOW VARIABLES WHERE variable_name = 'port';
phpmyadmin sql port config
Dis­play the MyS­QL Port in PhpMy­Ad­min.

That’s it. With this few steps, you have found the port num­ber of your MyS­QL data­ba­se.

How can I get the port of the MySQL database within Ubuntu using the shell? #

To do this, open a shell con­nec­tion to your ser­ver. You can use tools like put­ty to do this. After­wards, you only have to enter the fol­lo­wing com­mand lines to dis­play the MyS­QL port within the con­so­le:

mysql
SHOW GLOBAL VARIABLES LIKE 'PORT';
ssh mysql port auslesen
How to get the MyS­QL Port via Shell con­so­le.

Summary #

It’s that easy to read out the port of your MyS­QL data­ba­se. If you enjoy­ed this tuto­ri­al, you will love our sup­port. We deve­lop Word­Press pre­mi­um plug­ins, the­mes, web­sites and online shops. Check out our Word­Press agen­cy here.

Avatar of Marc Wagner
Marc Wagner

Hi Marc here. I'm the founder of Forge12 Interactive and have been passionate about building websites, online stores, applications and SaaS solutions for businesses for over 20 years. Before founding the company, I already worked in publicly listed companies and acquired all kinds of knowledge. Now I want to pass this knowledge on to my customers.

Similar Topics

Comments

Leave A Comment