Главная страница » Как узнать порт базы данных mysql

Как узнать порт базы данных mysql

  • автор:

What Is Default MySQL Port Number? [MySQL Server Port]

Do you know what’s the default SQL Port number that is used to access MySQL Database is? This article will brief you about what is MySQL Port and the Default MySQL server post.

List of content you will read in this article:

  • 1. What is Default MySQL Port Number?
  • 2. Check MySQL Port Number Used by MySQL Server
  • 3. How to Change Default MySQL Port Number?
  • 4. Various MySQL Ports
  • 5. Take Away

MySQL is a database management system used in a network to add, access, and process the data stored in a database. To connect directly or access your MySQL database or connect a different application to the database, you should have information such as the MySQL port number. Inside this article, you will get detailed information about the default Mysql port number and what it is, and how to change default MySQL port.

What is Default MySQL Port Number?

For your database, the default MySQL port number is 3306. While most applications will set the port number by default, in other cases, it may change. The port number may also change for security purposes. It may also change because another application already uses the database port number.

The MySQL protocol uses the default port to connect to utilities such as ‘mysqldump’ and MySQL clients.

Are there vulnerabilities when using the port?

The MySQL server is vulnerable to attacks when the default port 3306 is opened. Thus, the user has to explore other secure options if they want to access the database remotely.

Instead of using the default port, consider options like an SSH tunnel. The other option is restricting the IP addresses that can access the port to prevent connection by suspicious hosts. It doesn’t mean that MySQL will always use it. Running a short SQL query can help you identify the port your MySQL is running on.

Check MySQL Port Number Used by MySQL Server

You might find that one to even ten ports are used in your MySQL ecosystem. The port in use is essentially determined by the components in use, what has been enabled, how your apps connect, and the general characteristics of the MySQL environment.

The ideal way to use the ports is to make them wide enough to accommodate the different components while at the same time blocking out untrustworthy hosts.

There are several ways to establish the port your MySQL server listens to. If you are connected to your MySQL server, you can run the query «show variables where variable name in (‘hostname,’ ‘port’).»

If you are using Windows, you can check the MySQL port number in the configuration file.

Here are the steps.

Step 1: Go to «my.ini file»

Step 2: Open the «Services» window and find properties; then, you will find the location of the my.ini file.

Step 3: Open the .ini file

After finding the file’s location, find the MySQL port that is listening in Windows.

How to Change Default MySQL Port Number?

Changing your default MySQL port can protect you from unauthorized access through brute-force scripts. While non-standard ports may enhance your security, it only extends the time it takes for successful hacking to go through. Therefore, it would help if you had other security measures in place.

You may also require a port change if the standard 3306 is busy.

You can change the default port number of your MySQL server by following the below-listed steps.

Step 1: Open the «my.ini» file in the MySQL installation directory

Step 2: You will see the port with the default number 3306

Step 3: Change the port number 3306 to your desired number

Step 4: Save the changes so that the «my.ini» file is saved

Step 5: Restart your MySQL server so that it picks the changes.

You can then open the «my.ini» file in the server’s installation directory. When you restart MySQL, it will start listening to the new port number.

Various MySQL Ports

MySQL Port awareness is critical as it helps you understand when they will be used.

1. Port 3306/TCP

The default port 3306 connects MySQL clients to the MySQL server. The communication on this port is also encrypted by default. The direction of communication on this port is from the client to the server and is required unless X protocol is used.

2. Port 33060/TCP

Communication from this port is from the MySQL client to the server and is also encrypted. The port is also necessary for communication unless the default 3306 is being used.

3. Port 33062/TCP (default)

The communication on the port is from the client to the server and is also encrypted. Note that this MySQL port is particularly configured to support administrative connections. The administrative interface of MySQL makes it for operations like the administration of users, configuration of servers, viewing logs, and exports and imports.

4. Port 33061/TCP

33061/TCP alongside 33060/TCP and 3306/TCP are categorized as shell ports. Port 33061/TCP is required for running InnoDB Cluster. The communication on the port is also encrypted. The port’s key role is to check a server during the configuration of the InnoDB Cluster.

5. Port 22/TCP

MySQL workbench integrates administration, database design, maintenance, creation, and SQL development. The visual database design tool integrates all the said elements into a single development environment in the database system.

Port 22/TCP is a workbench port whose direction of communication is from the MySQL workbench to the server. Communication rides on a connection through an SSH tunnel.

Take Away

Being aware of the different MySQL ports is important. You need to understand what they are, who uses them, what uses them, when the ports should be used, level of security in terms of encryption and access limitations. This is the best information we have given about MySQL port, default MySQL port number, and various port no of MySQL. Suggest your feedback via below given comment box.

People also read:


I’m fascinated by the IT world and how the 1’s and 0’s work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited ‘master chef’.

What Is the Default MySQL Port Number?

mysql port

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.


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 host – learn 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.

Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:

  • Easy setup and management in the MyKinsta dashboard
  • 24/7 expert support
  • The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
  • An enterprise-level Cloudflare integration for speed and security
  • Global audience reach with up to 35 data centers and 275 PoPs worldwide

Get started with a free trial of our Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.

How do I find out my MySQL URL, host, port and username?

I need to find my MySQL username. When I open the MySQL command line client, it only asks me for my password. I don’t remember my username. And for connectivity with JDBC, I need the URL, host and port number. Where do I find all of these?

12 Answers 12

If you’re already logged into the command line client try this:

It will output something similar to this:

In my example above, I was logged in as root from localhost .

To find port number and other interesting settings use this command:

If you want to know the port number of your local host on which Mysql is running you can use this query on MySQL Command line client —

It will give you the port number on which MySQL is running.

If you want to know the hostname of your Mysql you can use this query on MySQL Command line client —

It will give you the hostname for mysql.

If you want to know the username of your Mysql you can use this query on MySQL Command line client —

It will give you the username for mysql.

Nikhil Agrawal's user avatar

For example, you can try:

Dmitry Matrosov's user avatar

If you don’t know the exact variable name use like , as the result may contain more than 500 rows:

Alex M's user avatar

If using MySQL Workbench, simply look in the Session tab in the Information pane located in the sidebar.

enter image description here

Jacob Stamm's user avatar

Adeel Ansari's user avatar

Easiest way is probably using command status; In the output you’ll find database, user, host and port:

Igor Lopatka's user avatar

If you use phpMyAdmin, click on Home , then Variables on the top menu. Look for the port setting on the page. The value it is set to is the port your MySQL server is running on.

Here are the default settings

default-username is root
default-password is null/empty //mean nothing
default-url is localhost or for apache and
localhost/phpmyadmin for mysql // if you are using xampp/wamp/mamp
default-port = 3306

Inzimam Tariq IT's user avatar

For Example in my case : karola-pc is the host name of the box where my mysql is running. And it my local PC host name.

If it is romote box than you can ping that host directly if, If you are in network with that box you should be able to ping that host.

If it UNIX or Linux you can run «hostname» command in terminal to check the host name. if it is windows you can see same value in MyComputer-> right click -> properties ->Computer Name you can see ( i.e System Properties)

How to check what port mysql is running on

How can I check what port it is running on the unix server that I have to upload the app to.

10 Answers 10


And that indicated that I was using port 3306 and that my search for the error continues.

The best way to actually know what application is listening to which interface and on what port is to use netstat

You can do this as root:

It will list out all the listening services like this:

The last column shows you that mysqld bound itself to port 3306 listening on all interfaces.

In fact, this works for everything, not just mysql. You can also use it non TCP sockets.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *