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:
netstat -tlnp
It will list out all the listening services like this:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 25934/mysqld
tcp6 0 0 :::22 :::* LISTEN 7964/dropbear
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.
I did
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.
Enter via terminal to mysql:
mysql -u root
and then type the following in the mysql prompt:
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';
This worked for me.
If you really want to confirm that it is running on the port you can telnet into the port while the process is up like so:
You'll see it report that you're connected to mySQL.
Alernatively, you can find the process's PID using ps and grep:
and then put that pid into lsof to print out all the open file descriptors. You'll find the port the process is bound to near the top.
MySQL defaults to port 3306 unless you specify another line in the
/etc/my.cnf
config file.Unless your
/etc/my.cnf
contains something likeThen it is very likely you are using the default port.
An alternative method to the ones already listed (and not as good but hey, it works).
The uid 27 line is the mysqld process' listening socket, and 0CEA is hex for 3306.
Ok, this works on my linux box, but I'm not sure that Unix will store the cnf file in the same place.
cat /etc/mysql/my.cnf | grep 'port'
you may try tailing the mysql log....try running
while restarting mysql by
on another ssh terminal/tab. The port on which its listening will be displayed in the log as follows:
If you try this: $ grep port /etc/mysql/mysql.conf.d/mysqld.cnf
you will see which port you are looking for.
above commands did not help me in my mac.
I used
lsof -i TCP:3306
to find out the mysqld process. which was actually listenting into *.mysql