Connect to MySQL Server on Linux From Windows

  • Avinash
  • 0
  • Jun 22, 2012
  • Database

Here I come with quick tip. This is about when you find problem when your MySQL Server is running on Linux machine and you are trying to connect from Windows Machine.

You might think its should not be a problem, but the fact is that, you will face problem when you have such condition where MySQL Server is on Linux Machine and you try to connect from different or Windows Machine. Let me explain you the reason for the same.

Main reason for this problem bind-address setting in MySQL Configuration File. bind-address parameter is used to let MySQL Server know from which server it can accept TCP/IP connections. You got the problem now? If not yet then continue reading.

So when you setup the MySQL server on Linux machine, it sets MySQL Server to accept connection from local IP only (i.e 127.0.0.1). So it allow TCP/IP connection from same machine only.

# Local Machine Only bind-address=127.0.0.1
  # Local Machine Only
  bind-address=127.0.0.1

What to Change?

As per the above code it will allow connections from Local machine only. So now if you want to allow from specific IP then you can assign that IP over here. You need to make one alteration in my.cnf file.

# Specific IP bind-address=57.58.25.1
  # Specific IP
  bind-address=57.58.25.1

But what if you want to allow connections from any IP? You just need to set the IP to 0.0.0.0, have a look at below code block for the same.

# All IP bind-address=0.0.0.0
  # All IP
  bind-address=0.0.0.0

Once you are done with editing the MySQL Configuration file, you need to restart the MySQL Service. You can use below command for the same in terminal.

sudo /etc/init.d/mysql restart
  sudo /etc/init.d/mysql restart

You will need ROOT permission to execute above command.

Have you ever gone through above situation? If Yes then Share with all for how you have handeled the situation. Because sharing is caring.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: