Database

Connect to MySQL Server on Linux From Windows

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 [code]bind-address[/code] 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.

[cc lang=”mysql”]
# Local Machine Only
bind-address=127.0.0.1
[/cc]

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.

[cc lang=”mysql”]
# Specific IP
bind-address=57.58.25.1
[/cc]

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.

[cc lang=”mysql”]
# All IP
bind-address=0.0.0.0
[/cc]

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.

[cc lang=”c”]
sudo /etc/init.d/mysql restart
[/cc]

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.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *