Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 18
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Find out what port MySQL is using or running


    How can I find out what port MySQL is running? The default is 3306 but this port is closed on my server, however MySQL is fully operational.

    The server is running GNU/Linux

    Cheers
    Chris

  2. #2
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    hi,


    what does say the following
    Code:
    netstat -an | grep -i mysql
    Linux and me it's a love story

  3. #3
    Ok that command returns:
    Code:
    unix  2      [ ACC ]     STREAM     LISTENING     6870   /var/lib/mysql/mysql.sock
    The port is still closed when I try to connect from remote.

    I'm trying to Install JasperServer, when I tell it my MySQL port (tried 3306 and the above one) it says no server found on that port.

    Cheers
    Chris

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined! sanjaykatiyar's Avatar
    Join Date
    Mar 2007
    Location
    Bangalore
    Posts
    97
    The command returns I-Node not the port on which mysql is running.

    [root@localhost temp]# netstat -an | grep -i mysql
    unix 2 [ ACC ] STREAM LISTENING 6321 /var/lib/mysql/mysql.sock

  6. #5
    Ok, how would I find the port it's running on?

  7. #6
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    Quote Originally Posted by sanjaykatiyar View Post
    The command returns I-Node not the port on which mysql is running.

    [root@localhost temp]# netstat -an | grep -i mysql
    unix 2 [ ACC ] STREAM LISTENING 6321 /var/lib/mysql/mysql.sock
    yeah he is right , this is the I-Node.

    try this
    Code:
    lsof -i4 -P | grep -i mysql
    Linux and me it's a love story

  8. #7
    khafa, that command returns nothing, but if i remove the end bit '| grep -i mysql' the command returns a large list of ports.

  9. #8
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    hummm,


    can you get the mysql process id?
    Code:
    ps -ef | grep mysql
    Linux and me it's a love story

  10. #9
    That returns:
    Code:
    mysql     3029  2996  0 Apr16 ?        00:04:28 /usr/libexec/mysqld --defaults-file=/etc/my.cnf --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock

  11. #10
    Linux Engineer khafa's Avatar
    Join Date
    Apr 2008
    Location
    Tokyo, Japan
    Posts
    858
    try this
    Code:
    /usr/sbin/lsof -a -i -p 3029
    if this does not give anything you can remove -a -i and run it again. but this might give a bunch of output so you have to search the associated port from that output
    Linux and me it's a love story

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •