0

trying to allow site1 to access a db on site2. site2 has site1 on the allow list for remote access.

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');


$host="host.com"; // Host name 
$username="user"; // Mysql username 
$password="pw"; // Mysql password 
$db_name="mydb"; // Database name 
$tbl_name="userCred"; // Table name

 // Connect to server and select databse.
 $link=mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
?>

i am getting the following error:
" Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'user'@'ans70.midphase.com' (using password: YES) in /home/site/public_html/subsite/remote.php on line 13"

3
  • Are you sure your user name is 'user'? Commented Aug 25, 2010 at 2:13
  • pablo yes. i dummy-fied my post here to make it anonymous. Commented Aug 25, 2010 at 2:17
  • Are you sure the mysql instance allows remote connections? Commented Aug 25, 2010 at 2:27

1 Answer 1

2

The MySql user must have the correct host set. If the user is set as localhost then that user can only connect from localhost and not from the remote machine where your PHP code is running from.

This is covered more here http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.