Reputation: 1851
I am trying to run a mysqldump
using a cron
job. I get the following error:
Enter password: mysqldump: Got error: 1045: Access denied for user 'user_name'@'localhost' (using password: NO) when trying to connect
Here is the line of code trying to connect:
$command = "mysqldump --opt -h ".$dbhost." -u ".$dbuser." -p ".$dbpass." ".$dbname." | gzip > ".$backup_file;
system($command);
Why is it saying (using password: NO)?
Upvotes: 0
Views: 124
Reputation: 39365
There shouldn't be any space between the -p
and your password
.
For example, this is correct:
-pPASSWORD
This is wrong
-p PASSWORD
And you are doing:
-p ".$dbpass."
^ space here
Upvotes: 4