If you want to connect directly to your MySQL database or connect another application to your database, you’ll need to know the MySQL port, along with some other information.

The default MySQL port is 3306, so you should be able to use “3306” as the port for most situations. In this brief article, we’ll share more about how to find the MySQL port and connect to your database. We’ll also answer some FAQs about MySQL and port 3306.

If you’re hosting your WordPress site at Kinsta, you’ll be able to access your database using phpMyAdmin or a direct connection. Kinsta also automatically optimizes your WordPress site’s database every week.

MySQL Port FAQs

Let’s start by addressing some of the most common questions around the MySQL port.

What Port Does MySQL Use?

MySQL uses port 3306 by default.

What Is the Use of Port 3306?

Port 3306 is the default port used for the MySQL protocol. You’ll use it to connect with MySQL clients and utilities such as mysqldump.

Is MySQL Port 3306 TCP or UDP?

The default MySQL port 3306 is TCP (Transmission Control Protocol).

Is There a MySQL Port Vulnerability? Is It Safe to Open Port 3306?

In general, you should not open port 3306 as it can make your server vulnerable to attack.

If you need to connect to your database remotely, there are more secure options than opening port 3306, such as using an SSH tunnel.

If you must open port 3306, make sure to restrict which IP addresses can access it so that it’s not accessible from untrusted hosts.

How to Find MySQL Port With SQL

Even though the MySQL default port is 3306, that doesn’t always mean your MySQL service will always use that port. If you want to verify the port or see if MySQL is using a different port, you can find the MySQL port using a short SQL query.

At Kinsta, you can run this query using phpMyAdmin, which you can access from the Kinsta dashboard. We’ll also tell you how you can remotely connect to a MySQL database in the next section.

In phpMyAdmin, select your database on the left and then go to the SQL tab.

In the Run SQL query box, enter the following:

SHOW VARIABLES WHERE Variable_name = 'port';

Then click Go:

How to find the MySQL port in phpMyAdmin
How to find the MySQL port in phpMyAdmin

On the next page, you should see the port number in the Value column. Again, the MySQL port is 3306 by default, as you can see in the screenshot below:

The MySQL port number after running the query
The MySQL port number after running the query

How to Connect to a MySQL Database

If you’re hosting at Kinsta, you can easily access your database from your MyKinsta dashboard using phpMyAdmin. For more information, check out our full post on using phpMyAdmin to access your WordPress database at Kinsta.

Kinsta also supports direct database access if you prefer to use other tools such as TablePlus, HeidiSQL, Sequel Pro, MySQL Workbench, etc.

The most secure method to remotely connect to your MySQL database is with an SSH tunnel. Kinsta provides SSH access on all WordPress hosting plans, so you can use this secure method to connect to your database.

To connect to a MySQL database using these tools, you will typically need your:

  • MySQL hostlearn what it is and how to find it
  • Database username, password, and name – you can find these in your Kinsta dashboard
  • MySQL port – Kinsta uses default port 3306
  • SSH credentials – you can find these in your Kinsta dashboard

For step-by-step instructions on where to find this information and how to use different tools to directly connect to a MySQL database, you can follow our direct database access tutorial.