AssemblyX
AssemblyX

Reputation: 1851

cron mysqldump saying not using password

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

Answers (1)

Sabuj Hassan
Sabuj Hassan

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

Related Questions