what's the advantage of outputting audio through the line out vs. headphone out?
November 10, 2004 5:44 PM   Subscribe

How would one set up a remote MySQL connection? [MI]

I'm a college student helping out with a local IT project. However, we are having connection issues.
We have my computer located in my room. We have the computer running php and mysql(current builds). How is it possible for me, on my computer, to establish a regular ol' connection to the mysql server. Obviously, localhost will not do. Help, thanks.
posted by Scottk to Technology (8 answers total)
Response by poster: Would anything need to be configured on the machine running the php and mysql? I imagine that's half the problem.
posted by Scottk at 5:46 PM on November 10, 2004

i don't know a ton about sql, but if you're trying to make a connection from your computer to the sql server, you'd use the default port (for mysql) of 3306 and the IP of the sql server in question, and also possibly a username/pass.

you can test this with one of those MySQLAdmin thingies or whatever.

sorry if i'm stating the obvious, or totally misunderstanding the question. I just thought i'd write something for you to try right away until someone more knowledgable happens along. \

either way, i have to go home from work. good luck!
posted by fishfucker at 5:53 PM on November 10, 2004

Response by poster: Thanks, I would never rule out something as simple as that. Unfortunately, I have to wait until tomorrow morning (EST) to try any of the suggestions posted. I'll for sure give it a shot.
posted by Scottk at 5:56 PM on November 10, 2004

Scottk, I'm not sure if I understand exactly how we can help, but here are a couple of things: the account you use to connect remotely should have the proper Host in the "user" table of the "mysql" permission database. You can use either the exact IP you will be connecting from, or the character '%' if you are connecting from many different IPs. (This obviously creates a bit of a security risk, so keep that in mind.)

If you are going to be remotely logging to MySQL itself from Linux, add the -h flag to indicate where the database is. (ie. "mysql -h -u remoteuser -p"

Hope that helps!
posted by jess at 6:14 PM on November 10, 2004

I need to know this every year or so and have usually forgotten exactly how it's done by the time I get around to it again, but I think you essentially need to create a user who can either log in from any host, or create one for each host you may log in from. You do this using the GRANT command. Google for something like "using MySQL Grant Tables" or something to come up with tutorial articles like this one. There's probably something better out there.
posted by weston at 6:15 PM on November 10, 2004

You have to:

1) Make sure that port 3306 is open on the server computer so your client can connect to it. Check the server's firewall, if any.

2) Configure MySQL to allow access from a remote machine. (If your server is running Linux, this is probably your problem.) You modify the grant tables in MySQL to create a user that can access the server from a remote machine. One way to do this is to use the mysql command on the server to run a command like this:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'fred'@'%' IDENTIFIED BY 'pass123'

This means that "fred" on any external machine can connect to the server and do whatever he wants to any table, assuming he uses the password "pass123". (Note that this really isn't very secure; before production, you should restrict "fred" so that he only has rights on the databases he needs, and only has privileges like SELECT, INSERT, UPDATE, and DELETE. The minimum set of things that your application requires.)

3) In your PHP code, connect as user "fred", password "pass123" on server < the ip address of your server>.

That's basically it.
posted by jmcmurry at 6:35 PM on November 10, 2004

In order to do any of this, you have to make sure mysqld is actually listening for a connection. Many distributions set it not to listen for connections by default for security reasons. Check your my.conf AND the script that starts mysqld for two arguments, and if either is there, remove it: skip-networking and bind-address=

If you want to keep things secure and you can ssh to the system, perhaps an ssh tunnel would be the best idea. Then, you can set bind-address=, ssh into the machine with the tunnel, and access things securely.
posted by zsazsa at 7:05 PM on November 10, 2004

Also, I wonder what use you will make of this remote connection. I have gone several years without it and not once did the question arise.
posted by billsaysthis at 9:07 PM on November 10, 2004

« Older Prices in the UK vs. Canada   |   I'm switching from IE to Firefox. What extensions... Newer »
This thread is closed to new comments.