Ad

Access Denied For Mysqldump Command On Forge With Digitalocean

- 1 answer

I'm running an artisan command that should backup my database, but I get this error:

mysqldump: Got error: 1045: Access denied for user 'forge'@'45.65.33.154' (using password: YES) when trying to connect

This is the command:

exec('mysqldump -u '.$user.' -h '.$host.' -pmysql-pass '.$password.' forge > storage/files/'.$fileSql);

It's using the right username and password so I really can't see where the problem is. On my local machine it worked perfect. Of course I configured all the environment variables properly.

Ad

Answer

Your parameter is wrong for the password, it should be:

exec('mysqldump -u '.$user.' -h '.$host.' --password='.$password.' forge > storage/files/'.$fileSql);

You may need to grant access using this:

GRANT ALL ON yourdb.* TO [email protected] IDENTIFIED by 'the-password-goes-here';
Ad
source: stackoverflow.com
Ad