Enable remote access to MySQL database server

Animorphs

Verified User
Joined
Dec 6, 2004
Messages
13
I'm unable to locate the /etc/my.cnf file where I need to edit to include port and bind-address.

Is there any other method to enable remote access to MySQL database server?

Any help/ guidance is much appreciated.

Thanks in advance.
 
There isn't an /etc/my.cnf file unless you create one.

I think you can actually program the database to allow remote access on a database-by-database basis, but I'm not sure, and I'm not a MySQL programmer, so hopefully someone else will answer.

Jeff
 
Quick and Dirty Method

(1) Open port 3306 (TCP Inbound) on your firewall, because surely you have one. :)

(2) Use your favorite text editor and create your /etc/my.cnf if it doesn't exist yet. Otherwise, skip this step.

Code:
nano /etc/my.cnf -w

(3) Add the following to the file:

Code:
[mysqld]
user = mysql
port = 3306
bind-address = xx.xx.xx.xx

Obviously, replace xx.xx.xx.xx with the MySQL server IP. You may not even need the bind-address parameter if you have a single IP and nothing else. Then Ctrl-X out of it and save it.

(4) Restart MySQL

Code:
service mysql restart
or
Code:
/etc/init.d/mysql restart

(5) Login from your remote location. Example:

Code:
mysql -u username –h xx.xx.xx.xx –p

There are many different ways to delimit and specify parameters for access control. But the above method should open port 3306 for pretty much all remote users provided they have the right privs (use phpMyAdmin or something to check your user has "Any Host" specified in it's privileges). If you use a GUI interface for accessing your MySQL server remotely, make sure you specify port 3306 when logging in. You may even try "telnet xx.xx.xx.xx 3306" from a command prompt in Windows to see if your server is even responding on that port. If not, keep messing with your firewall settings. And don't forget to restart the firewall as well, or if it requires certain IPtables or chain changes, just reboot the darn thing.

Hope this semi-cheesy guide can assist you! :D
 
Doesn't work for me :(

I did exactly what you described, but mysql restart failed.

I have configured APF and opened port 3306..

Do you have any idea what could be wrong?

Thanks.
 
Did you open up the port in both direction for all protocols? On both servers?

Did you try it with your firewalls off for both servers?

Jeff
 
Just a thought here but if you go to a database in question through DirectAdmin

i.e. domain name [user level] > MySQL Management > [click the database name from the list of databases]

and at the bottom under Access Hosts, you can add the IP of the other machine in question that you want to be able to access the database.

That and opening the firewall ports for 3306 should work.

Does for me anyhow :D

HTH.
Nath.
 
The APF config on both servers allows everything on port 3306.

When testing making connection to the remote server, it works. But only when I use the real IP instead of localhost.
I want the server to recognise localhost as the remote database server.
So adding the ip to "access hosts" in DA is no solution unfortunality. :(
 
localhost cannot and will not ever be located as any other server but the server on which it gets looked up.

Why? Because localhost is a reserved word in all operating systems meaning this machine.

Changing it to mean something else is possible in your /etc/hosts file, but if you do, a lot of network functionality will refuse to work properly. You'd be entirely on your own, no one on any platform will be able to help you with the errors.

Jeff
 
The poster is running a patch in a particular version of MySQL which let's the local instance of MySQL (which still runs on the local machine) act as a proxy, sending all MySQL queries to a different server.

Both linux and unix have a patch command; if you're using that particular version of MySQL you can patch the source code and compile from source.

My guess is that teaching you how to run the patch program, and then how to compile from scratch on your platform of choice, is probably beyond the scope of the DirectAdmin forum. Perhaps I'm wrong and someone else will be able to explain the details to you. Otherwise perhaps a good systems administration resource for your OS of choice may help you.

Jeff
 
Yes I agree, its not the right subject for here.

On the other hand.. I expected more people to struggle with this.
Unfortunately, I have no time to solve it now.. if I find a solution I will post it here.

Thanks for replying.

Best regards
 
Back
Top