Connecting to a remote db

SpaceshipSpaceship
Watch

m12345

New Member
Impact
0
Hello guys,

This questions is about databases. Lets say i have a database at mywebsite1.com and i want the php script at mywebsite2.com to access the same databases as mywebsite1.com...

So in my php configuration file (where the db login details go), i assume

$dbhost='localhost'; would be changed to $dbhost='SOMETHING ELSE'; ???

I need to know what comes instead of localhost and where can i find that from my server. I was able to find something called

MYSQL_SOCKET /var/run/mysqld/mysqld.sock

is that it?

Thanks,
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Hi!

If those both sites are located on the same server then you just can use localhost, if it uses a other hosting provider then you have to enter the domain name:

dbhost='website.com';
 
0
•••
Also, in cpanel under MySQL, theres a section that allows people to connect to the domain, so if your connecting from a different host, then you have to allow the IP from the server your connecting from onto the one your connecting too.

Hope you under stand :P

PJ
 
0
•••
m12345 said:
Hello guys,

This questions is about databases. Lets say i have a database at mywebsite1.com and i want the php script at mywebsite2.com to access the same databases as mywebsite1.com...

So in my php configuration file (where the db login details go), i assume

$dbhost='localhost'; would be changed to $dbhost='SOMETHING ELSE'; ???

I need to know what comes instead of localhost and where can i find that from my server. I was able to find something called

MYSQL_SOCKET /var/run/mysqld/mysqld.sock

is that it?

Thanks,

It is simple to change the host but the issue you will run into if you are using a hosting company is that most hosts do not allow external MySQL access, meaning it could be impossible to connect to an external MySQL database.

If that database is accessibile from the outside on a server you control then it will be no problem of course but by default MySQL does not permit remote access for security reasons.
 
0
•••
Depending on the host, this might not be possible. You could try, but there's no guarantee it'll work. Anyways, I agree with xlusive, or you can try [email protected]
 
0
•••
Thanks to all!

I will try it.
 
0
•••
Appraise.net

We're social

Spaceship
Domain Recover
CatchDoms
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back