peterbz Posted April 20, 2008 Share Posted April 20, 2008 I was wondering how you can connect to a MySQL database on another server if you have the username and password What I want to do is to retrieve data from a table from a MySQL database on another server and update the data to another server. I was just wondering if this is possible. Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 Yes, you can specify the a different hostname in the '$server' argument in mysql_connect, connect to that server, get your data and then make another connection to your other server and insert/update the data. http://us.php.net/mysql_connect Or if you have access to the command line on a computer that has MySQL installed, you could do that using some of the mysql tools ( eg, mysql, mysqldump, etc ). Quote Link to comment Share on other sites More sharing options...
peterbz Posted April 20, 2008 Author Share Posted April 20, 2008 What would the host name be if I were trying to connect to for example a site like http://vision-blog.info Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 You would have to contact the hosting company or webmaster to figure that out. Most hosting companies do NOT allow the MySQL server to be remotly accessed and if they do, there is now way of guessing which hostname the server runs at. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 20, 2008 Share Posted April 20, 2008 So, in my experience, it should run just entering "vision-blog.info" as the host, be sure though to have your host provider you are accessing white-list the IP address of your website Quote Link to comment Share on other sites More sharing options...
peterbz Posted April 20, 2008 Author Share Posted April 20, 2008 Will I be able to find the host name if I have access to phpMyAdmin for my MySQL server Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 20, 2008 Share Posted April 20, 2008 Yes, at the top you should see something like this: Server: localhost:3306 - Database: database_name - Table: users The "Server" is the server you use Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 But the server is 'localhost'. You need to find a public hostname for that server. It's hard to get. You might have to really bother you webhosting company to get it. With the web hosting companies I've worked with, they have never given out their public SQL server hostname with out you having to ask for it. Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 20, 2008 Share Posted April 20, 2008 dptr; wouldn't just using the server IP work? or whatever the address is in the address bar..? Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 Yes, an IP address will work or anything that will give you an IP address. If the server admin has allowed remote access to the DB server, he probably didn't put it on the same hostname as the webserver ( the address you see in your address bar ) or at least i"ve never seen it done this way. But it's worth a try! Quote Link to comment Share on other sites More sharing options...
monkeypaw201 Posted April 20, 2008 Share Posted April 20, 2008 : I have, i actually run it that way Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted April 20, 2008 Share Posted April 20, 2008 Me too, but I don't see that way very often. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.