Hi there,

I used code to fetch email address record from table abc on server but shows

Access denied for user 'mysqluser'@'serverip' (using password: YES)

/********code ********/
include "connection.php";
$tableName  = 'abc';
$todayDate=date("m-d-Y H:i");
$backupFile = '../backup/abc_'.$todayDate.'.csv';
$query      = "SELECT email_address INTO OUTFILE ".$backupFile."  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '&quot;'
  LINES TERMINATED BY 'auto' FROM ".$tableName;
$result = mysql_query($query);

/********code ********/


Edited by __avd: Added [code] tags.

6 Years
Discussion Span
Last Post by gptArun

connection.php is where the error is being generated? I'm guessing you got that connection.php code from somewhere else, but failed to update it with your actual MySQL connection information.


But same connection is working with other files. On same folder "connection.php" resides.


This error usually means the username and password specified are either invalid or have insufficient permissions to the database.

So perhaps try your regular cpanel details in the mysql_connect() function as that gives you full permissions associated to your cpanel account provided your using cpanel. If your not using cpanel then use the details your host has provided when setting up the hosting account although the password may have changed since depending on how much you have changed the settings. If however your using something like wampp or xampp then I would suggest using the root username and password.


thanks for all replies. actually problem is with HOSTNAME. HOSTNAME which i used don't have GRANTS in information_schema database. IP was defined there.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.