Bind Address missing in my.cnf in MYSQL centos

Megha Sharma picture Megha Sharma · May 15, 2014 · Viewed 19.3k times · Source

I have hit a problem, when I edit the my.cnf for MySQL, the bind-address line is not in the file.

Here is the content of /etc/mysql/my.cnf:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

Kindly help me to achieve this.

Answer

mdh.heydari picture mdh.heydari · Oct 22, 2015

Just add these lines to mysqld section depending on your preferences:

  1. If you want it to only be accessible through localhost:

    bind-address=127.0.0.1

  2. If you want it to be accessible through an interface which assigned an IP address of XXX.YYYY.WWW.ZZZZ:

    bind-address=XXX.YYYY.WWW.ZZZZ

  3. If you want it to be accessible through all interfaces available, This is not recommended except when you properly configured your firewall for it:

    bind-address=0.0.0.0