Thursday, November 3, 2016

How to check which port number mysql server is running on linux ?

Method 1:

To find a listener on a port, do this:

root@linuxforfreshers.com:~$netstat -tln | grep 3306
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN     

Or

root@linuxforfreshers.com:~$netstat -tlpn | grep mysql
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      870/mysqld


Method 2:

root@linuxforfreshers.com:~$grep port /etc/mysql/my.cnf
# One can use all long options that the program supports.
# It has been reported that passwords should be enclosed with ticks/quotes
port                 = 3306
port                 = 3306

Method 3:

Using Mysql Query
root@linuxforfreshers.com:~$  mysql –u username –p password

mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| port          | 3306  |


+---------------+-------+

No comments:

Post a Comment