Home Mysql MySQL default port number in Linux

Related Tutorials


 
 

Share on Google+Share on Google+

MySQL default port number in Linux

Advertisement
In this tutorial I will explain you how you can login to your Linux box a root and then find the port number on which MySQL is running. The MyQL default port number is 3306. But if your MySQL server is running on deferent port then you should login to the Linux box as root and find out the port number.

MySQL default port number in Linux - How to find the default port number of MySQL in Linux?

If you are using MySQL database server installed on the Linux server and you are not aware on which port it is listening then this tutorial is for you. In this tutorial you learn "How to find the default port number of MySQL in Linux?". After find the port number you can connect to the MySQL server through your program.

First of all you should have access to the machine on which MySQL is running.

Login as root on the machine running MySQL server and then type mysql on the console. If you are able to login to the mysql using this then use the following sql command to find out the port number of MySQL server:

mysql> show variables like 'port';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |
+---------------+-------+
1 row in set (0.01 sec)

mysql>

The above sql will show you the port number of MySQL server.

If you are not able login to mysql then you can use the following command on the Linux console:

lsof -i4 -P | grep -i mysql

Following command will give you following output:

root@mail [~]# lsof -i4 -P | grep -i mysql
mysqld 23062 mysql 10u IPv4  ******* TCP *:3306 (LISTEN)

Here you can see the that this command is giving you the port number.

You can also find the port number from the /etc/my.cnf file. You can open the my.cnf file and look for the variable:

port = 3306

In this you have learned how to find the port number of MySQL server running on Linux machine.

More tutorials:

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 4, 2013

Related Tutorials

Discuss: MySQL default port number in Linux  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com