In order to be able to connect to your MySQL database, you need the port. The same applies to websites and online shops that you have created with WordPress, for example.
The standard value for the MySQL port of your database is: 3306. Most applications also set this value by default.
In this article, I will show you how you can find out the MySQL port to connect yourself or the application of your choice to your database.
Which port does MySQL use? #
By default, MySQL uses the port 3306. However, the port may have changed. On the one hand this can be used for protection, on the other hand it can be that the port has already been used by another application.
Is the MySQL port 3306 TCP or UDP? #
The default MySQL port is TCP (Transmission Control Protocol).
The TCP protocol is the most frequently used protocol on the Internet. In contrast to the UDP protocol, the data is checked for correctness when sending and receiving via the TCP protocol. If parts of the transmission are lost, they will be sent again.
The UDP protocol may be faster, but does not check the transmission for errors. Lost data cannot be requested again.
Is there a vulnerability in the MySQL port? #
In general, you shouldn’t open the MySQL port to the outside world. Instead, it is advisable to connect to the server via an SSH tunnel and then use it to establish the MySQL connection.
Applications like HeidiSQL or Datagrip support SSH tunnel connections.
If you still want to allow access via the port, you should specify that only selected IP addresses are allowed to access it.
How can I find the MySQL port with SQL? #
The easiest way to find out the port is directly via SQL and your PhpMyAdmin Interface. To do this, you first have to log in and then open the SQL console.
In the input field below, you can now insert the following SQL statement to display the port of your database:
SHOW VARIABLES WHERE variable_name = 'port';
That’s it. With this few steps, you have found the port number of your MySQL database.
How can I get the port of the MySQL database within Ubuntu using the shell? #
To do this, open a shell connection to your server. You can use tools like putty to do this. Afterwards, you only have to enter the following command lines to display the MySQL port within the console:
mysql
SHOW GLOBAL VARIABLES LIKE 'PORT';
Summary #
It’s that easy to read out the port of your MySQL database. If you enjoyed this tutorial, you will love our support. We develop WordPress premium plugins, themes, websites and online shops. Check out our WordPress agency here.
Comments