aarkeys Posted September 12, 2011 Share Posted September 12, 2011 Dear All, I am having 2 different DB on 2 different hosts. I am running MySQL Server on my local PC where the user is entering data in the tables. I have a website which has the identical DB on the web. I am able to connect to the database by using the codes on the server. I want to update the server DB with the local system DB by running one update command. I get the error "-SELECT command denied to user 'localusername'@'localhost' for table 'pst_data'" Given below is the code used for the process : //connecting the remote system DB $link = mysql_connect('IPAddress:3306', 'remoteusername', 'Password'); if (!$link) { die('Not connected : ' . mysql_error()); } $db_selected = mysql_select_db('remotedb', $link); if (!$db_selected) { die ('Can\'t use Remote System DB: ' . mysql_error()); } //connecting the local database on the webstite $weblink = mysql_connect("localhost","localusername","password"); if (!$weblink) { die('Not connected : ' . mysql_error()); } $webdb_selected = mysql_select_db('localwebdb', $weblink); if (!$webdb_selected) { die ('Can\'t use WebServer Database : ' . mysql_error()); } //query to fetch the records from remote ystem and insert into local website database $upd_Query=mysql_query("INSERT INTO localwebdb.`table` SELECT * FROM remotedb.`table` where field=' some condition' "); --------------------------------------------------- I have tested that I have connected the remote DB by running queries on the webserver. Could anyone bail me out so that i can copy the DB from remote to local Any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/246955-connecting-2-databases-on-different-hosts/ Share on other sites More sharing options...
dougjohnson Posted September 12, 2011 Share Posted September 12, 2011 Is the PHP script you are running on your PC or the remote server? The error is telling you that the user "localusername" does not have permission to use the "SELECT" command. If the script is running on the remote server, do you have a user set up on your local PC with permissions to execute your statement? Link to comment https://forums.phpfreaks.com/topic/246955-connecting-2-databases-on-different-hosts/#findComment-1268406 Share on other sites More sharing options...
aarkeys Posted September 13, 2011 Author Share Posted September 13, 2011 The PHP Script is running on the server. The server connects to the remote PC and i have tested it by querying the database at the remote PC. I am doing the following : 1) Connecting to the remote PC - successfully connected as i can query the remote DB 2) Connecting to the DB on webserver - successfully connected 3) The problem occurs only when i run the query to retrieve the records from remote and update the local webserver where it denies the permission. Link to comment https://forums.phpfreaks.com/topic/246955-connecting-2-databases-on-different-hosts/#findComment-1268596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.