6

I want to enable remote access to my MySQL server so I've set the bind-address option under [mysqld], which looks like:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
bind-address=**.**.**.66
port=3306
# skip-networking
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

When I comment bind-address, the server starts normally. However, when I comment it out it won't restart. The port is open and listens.

Can you please help me sort this out? Thanks

  • **.**.**.66 isn't a valid IP address... – womble Jul 19 '11 at 0:38
  • @womble, eh? Isn't that just standard address obfuscation? – Zoredache Jul 19 '11 at 0:41
  • @Zoredache: We don't know, do we? Perhaps that really is what he put in, and that's why it's not working. The correct way to obfuscate addresses is to use the RFC5737 documentation networks. – womble Jul 19 '11 at 0:43
  • 1
    Probably I should clarify this, in the actual my.cnf file I use the real IP address. I use * just to hide it here. – Vasilis Jul 19 '11 at 1:10
8

Why do you think you need to use bind-address to enable remote access?

Without the bind-address option try running the command netstat -ntlp | grep 3306. If you see output like below, then mysql is listening on every IP associated with the computer.

tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      23465/mysqld 

You only really need the bind-address if you want to listen on a specific IP. If you want to listen for requests on all addresses you should leave that commented out or set it to 0.0.0.0. Some packaged versions of mysql come with startup/maintenance scripts that will attempt to access mysql on 127.0.0.1. If you use the bind-address option then mysql will only be bound to that specific IP, and nothing else, possibly breaking any scripts that you currently have.

  • netstat: option -p requires an argument – Almo Dec 17 '13 at 20:59
  • It does not require an argument on the net-tools version of netstat on Linux. What OS are you running on? I know netstat has different syntax/options on Windows, and on BSD. – Zoredache Dec 17 '13 at 21:07
2

Maybe this will help some folks:

It appears that if bind-address is declared in 2 places, the service fails to restart.

Perhaps you quickly scanned your /etc/conf/my.cnf file and did not see a 2nd appearance of bind-address. However, note that the file may contain a !includedir directive, and some of those included files can contain a 2nd bind-address.

1

Make sure there isn't a stalled mysqld instance already started. Check

ps aux|grep mysqld

and kill all processes with

kill -9

then try to start mysqld again. Pay attention to mysqld processes in "Sl" state.

  • and make sure the sky isn't falling and that the power grid is still alive. Am I still breathing? – chicks Oct 20 '15 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.