What is the standard MySQL port?

Marc Wag­ner

July 12, 2021

3 min read|

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.

88e86fcb816eff22bc917094df2862d8dd5c0e978b333e6dd5f36f808990c261 96

Arti­kel von:

Marc Wag­ner

Hi Marc here. I’m the foun­der of Forge12 Inter­ac­ti­ve and have been pas­sio­na­te about buil­ding web­sites, online stores, appli­ca­ti­ons and SaaS solu­ti­ons for busi­nesses for over 20 years. Befo­re foun­ding the com­pa­ny, I alre­a­dy work­ed in publicly lis­ted com­pa­nies and acqui­red all kinds of know­ledge. Now I want to pass this know­ledge on to my cus­to­mers.

Hast du eine Fra­ge? Hin­ter­lass bit­te einen Kom­men­tar