ldoozer Posted November 26, 2006 Share Posted November 26, 2006 Does anyone know any reasons why i would get an error trying to connect to a database on another server. I have the correct hostname username and password? Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/ Share on other sites More sharing options...
SharkBait Posted November 26, 2006 Share Posted November 26, 2006 What is the error you are seeing?Perhaps the username you are using is not allowed to connect from outside the server? Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/#findComment-130666 Share on other sites More sharing options...
ldoozer Posted November 26, 2006 Author Share Posted November 26, 2006 Thanks SharkBait, The error was just a scripted error - cannot conect to mysql database. Could it be something to do with a security option then do you think? Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/#findComment-130674 Share on other sites More sharing options...
mainewoods Posted November 27, 2006 Share Posted November 27, 2006 if you are connecting from another host, the hostname specified in the connect statement has to be the host you are calling from, not the host the mysql is on. most shared hosts dont allow that and you would have to have a dedicated server with root access to the server to do that. Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/#findComment-130758 Share on other sites More sharing options...
ToonMariner Posted November 27, 2006 Share Posted November 27, 2006 ????The host name has to be the host of teh database - otherwise you'd never know where you are connecting to.There is the potential that the hosts of the database you are trying to connect to do not allow access from outside the server. BUT be absolutely sure you have the correct host name.You may also have to specify which port to connect on. Get in touch with the hosts of teh database you are trying to connect to and ask them exactly what details you need to connect remotely to the database. Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/#findComment-130765 Share on other sites More sharing options...
mainewoods Posted November 27, 2006 Share Posted November 27, 2006 what ToonMariner said about the hostname is correct. what I meant is that the mysql usernames/ passwords have to be set up to be called from a particular domain which is usually localhost. If you have a username/password that works on the server the db is on, then they will not work if called remotely. The difference, in mysql code is like this:[code]-The first account can access the bankaccount database, but only from the local host. -The second account can access the expenses database, but only from the host -whitehouse.gov. -The third account can access the customer database, but only from the host server.domain. To set up the custom accounts without GRANT, use INSERT statements as follows to modify the grant tables directly: shell> mysql --user=root mysqlmysql> INSERT INTO user (Host,User,Password) -> VALUES('localhost','custom',PASSWORD('obscure'));mysql> INSERT INTO user (Host,User,Password) -> VALUES('whitehouse.gov','custom',PASSWORD('obscure'));mysql> INSERT INTO user (Host,User,Password) -> VALUES('server.domain','custom',PASSWORD('obscure'));[/code]--that creates passwords for 3 different users in the mysql password tables--only the first which uses 'localhost' is allowed by most shared hosts for security reasons Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/#findComment-130785 Share on other sites More sharing options...
ldoozer Posted November 27, 2006 Author Share Posted November 27, 2006 Thanks for all the comments on this. I will be contacting the hosting company tomorrow and post a report of my findings.Thanks againSteve Link to comment https://forums.phpfreaks.com/topic/28562-connecting-to-a-database-on-another-server/#findComment-131056 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.