MySQL – Allow network connections to DB in CentOS 5

Weird issue.

I’ve got a CentOS 5 server running, and I can’t get MySQL to allow remote connections and local connections. IP Tables is setup correctly to allow the one remote server I need to connect to MySQL to do so.

skip-networking is commented out, and I don’t have a bind address.

Answer

First off, run something like this to see what you have now:

 [root@cacti ~]# netstat -lnpt | grep `cat /var/run/mysqld/mysqld.pid `
 tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      2814/mysqld

If you don’t see a line like that, check what command line options are being passed to your binary by running something like this

 [root@cacti ~]# ps auxfwww | grep mysql
 root     12754  0.0  0.0  61200   728 pts/1    S+   10:46   0:00  |                   \_ grep mysql
 root      2767  0.0  0.0  65976  1064 ?        S    Jul12   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --user=mysql
 mysql     2814  2.1  0.8 348652 16848 ?        Sl   Jul12 464:20  \_ /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock

And lastly, show us your networking options from my.cnf. By default mysql will bind to tcp 3306 on startup unless you tell it not to. If you see anything inside the [mysqld] section related to networking you could try starting with just commenting it out.

Also it might help to check the log. Its not very clear, but it will tell you if and when it binds to a port on startup like this

 [root@cacti ~]# grep port /var/log/mysqld.log
 Version: '5.0.45'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution

Attribution
Source : Link , Question Author : Devar-TTY , Answer Author : cagenut

Leave a Comment