PDA

View Full Version : Pointing dbhost/localhost to other server


rize
August 23rd, 2008, 04:35 AM
Hey :clown:

i've been trying to figure this out & googling for days but still haven't figured this out.. In wordpress how do i point my DBHOST to other server so that the other server is the one hosting my wordpress database?

Like in wordpress DBHOST is LOCALHOST right?

how do i make my other site(hosted on other server) host my wordpress site's database?

MKInfo
August 23rd, 2008, 05:04 AM
Tou have to change localhost to the db you are pointing it at.
ie. mysql.domainwhichthenewdatabaseison.com

rize
August 23rd, 2008, 05:25 AM
Tou have to change localhost to the db you are pointing it at.
ie. mysql.domainwhichthenewdatabaseison.com

oh.. i thought im supposed to write the url like http://newserv.com let me try your code.. :) thankss

editt;;
i get a :

Error establishing a database connection

Smurfwicked
August 23rd, 2008, 05:34 AM
Try this:

$dbh=mysql_connect ("server_name_here", "username_here", "pass_here") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("db_name_here");

rize
August 23rd, 2008, 05:40 AM
Try this:

$dbh=mysql_connect ("server_name_here", "username_here", "pass_here") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("db_name_here");

uhm in wordpress it's like this:
define('DB_NAME', 'blah_sl'); // The name of the database
define('DB_USER', 'blah_sl'); // Your MySQL username
define('DB_PASSWORD', 'sfas'); // ...and password
define('DB_HOST', 'mysql.newser.com'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

how do i change it into that? oh and in the server name how do you write it? just newserver.com? Sorry really don't know stuff bout this :(

MKInfo
August 23rd, 2008, 05:51 AM
replace 'mysql.newser.com' that bit with 'mysql.newserver.com'
I have only ever usd it with wordpress on Dreamhost so dunno if it works with any other host

obviously if the user/pass etc is different on the new db you will have to change that too.

rize
August 23rd, 2008, 06:05 AM
Try this:

$dbh=mysql_connect ("server_name_here", "username_here", "pass_here") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("db_name_here");

replace 'mysql.newser.com' that bit with 'mysql.newserver.com'
I have only ever usd it with wordpress on Dreamhost so dunno if it works with any other host

obviously if the user/pass etc is different on the new db you will have to change that too.

doesnt work for me :( im in hostmonster..

Smurfwicked
August 23rd, 2008, 06:30 AM
uhm in wordpress it's like this:
define('DB_NAME', 'blah_sl'); // The name of the database
define('DB_USER', 'blah_sl'); // Your MySQL username
define('DB_PASSWORD', 'sfas'); // ...and password
define('DB_HOST', 'mysql.newser.com'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

how do i change it into that? oh and in the server name how do you write it? just newserver.com? Sorry really don't know stuff bout this :(

I was trying to test it myself but my internet connection being lame (im writting this in notepad waiting for my connection to come back so I can quickly reply)! I am not sure if this would work on wordpress:

define('DB_NAME', 'layout_shout'); // The name of the database
define('DB_USER', 'layout_shout'); // Your MySQL username
define('DB_PASSWORD', 'shout'); // ...and password
define('DB_HOST', 'mysql.layoutshome.com'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

$dbc=mysql_connect ("mysql.layoutshome.com", "layout_shout", "shout") or die ('I cannot connect to the database because: ' . mysql_error());
@mysql_select_db ("layout_shout");

I think the remote server has to have networking turned on and I think port 3306 (not sure if thats the right port #) has to be open too. Saying that I'm not sure if its possible to be done on a server that you've got very little control over.

Why not just get a host that can provide you with a database?

*takes hammer to modem....*
edit: replaced with your settings

rize
August 23rd, 2008, 06:32 AM
I was trying to test it myself but my internet connection being lame (im writting this in notepad waiting for my connection to come back so I can quickly reply)! I am not sure if this would work on wordpress:

define('DB_NAME', 'layout_shout'); // The name of the database
define('DB_USER', 'layout_shout'); // Your MySQL username
define('DB_PASSWORD', 'shout'); // ...and password
define('DB_HOST', 'mysql.layoutshome.com'); // 99% chance you won't need to change this value
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');

$dbc=mysql_connect ("server_name_here", "username_here", "pass_here") or die ('I cannot connect to the database because: ' . mysql_error());
@mysql_select_db ("db_name_here");

I think the remote server has to have networking turned on and I think port 3306 (not sure if thats the right port #) has to be open too. Saying that I'm not sure if its possible to be done on a server that you've got very little control over.

Why not just get a host that can provide you with a database?

*takes hammer to modem....*

Yeh im thinking i need to do something in order to allow access.

Im trying to do this because my current host is ALWAYS suspending my site for CPU USage and im planning to transfer my database to another server(dedi).. Not sure if it'll help stopping/lessening my site's downtime though..

Smurfwicked
August 23rd, 2008, 06:36 AM
Just got a new idea, do you know the ip of the mysql server? if so you can try using "ip.for.server:3306" as the db_host

Pooraffiliate
August 23rd, 2008, 03:32 PM
Majority of hosts block access to mysql except on localhost. You normally have to set something up to allow the mysql to be accessed from a different IP so check for something in your new hosts CPanel.. normaly something about 'firewalls'