View Full Version : Remotely Connecting SQL Databases
XT-iZac
July 17th, 2008, 10:46
Well, Im not sure if its the right forum...But i need a bit of help with this...Well, i have a SQL database, that runs via WAMP. It contains some personal info, thus i don't want to run it on the web hosting companies MySQL service. I want to link the database to my server, but i don't know how...Meaning im not sure What to do in phpMyAdmin, i know that i can't use the default host as localhost anymore, so will someone point me to filling in the right info?
In this case, my
<?php
$host['naam'] = ' '; // my host
$host['gebruikersnaam'] = ' '; // my database username
$host['wachtwoord'] = ' '; // my database password
$host['databasenaam'] = ' '; // my database name
That's the file i need to fill up...Can anyone help?
themoose
July 17th, 2008, 12:25
Instead of localhost, put in the IP or routed domain of the server with mysql on it.
$host['naam'] = '127.0.0.1';
or
$host['naam'] = '98.01.23.45';
for example.
Dynash
July 17th, 2008, 12:41
you also need to enter the port.
$host['namm'] = '98.01.23.45:3306';
themoose
July 17th, 2008, 13:31
In my experience that hasn't been necessary. But if it doesn't work, put in the port :)
XT-iZac
July 18th, 2008, 09:12
It fails...
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on '116.14.252.253' (4) in /home/abc/public_html/config.php on line 7
Cant connect to the database
Written on Line 7:
$db = mysql_connect($host['naam'], $host['gebruikersnaam'], $host['wachtwoord']) OR die ('Cant connect to the database');
mysql_select_db($host['databasenaam'], $db);
Anything wrong with it?
themoose
July 18th, 2008, 09:45
Did you try putting in the port like dynash suggested?
$host['naam'] = '116.14.252.253:3306';
krakjoe
July 18th, 2008, 12:35
It's because when users are created, by default their permissions only apply to connections from localhost. More often than not you'll need to grant permissions using either wildcards or an IP address.
Login to phpmyadmin, select the database you're using for your personal data. Click the privileges tab, click the action icon next to the username you're using for a connection and change the Host dropdown and or text as appropriate.
Dynash
July 18th, 2008, 12:43
I was going to say that, but I never had time. Also, in your cPanel (if that is what you're using), you can use that feature, on the databases area, "Remote Connections" or something like that. To do it all automatically.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.