0

I am trying to backup my MySQL 8 database with the command line below but I got an error message.

How to make the backup ?

ubuntu@www-example-com ~ $ mysqldump -u root -p www_example_com > /var/www/www-example-com/share/www-example-com_$(date +%F).sql

-bash: /var/www/www-example-com/share/www-example-com_$(date +%F).sql: Permission denied
20f2c98f50
  • 39
  • 2
  • 10

2 Answers2

0

Did you try check permissions for all directory in "/var/www/www-example-com/share" path? Also, you could try using sudo (if you can)

Anaoliy Tk
  • 38
  • 1
  • 6
  • You don't need to check the permissions for all directories in that path. The user would need read permissions for each directory in the path `/var/www/www-example-com/` and then read/write permissions for `share/`. – Christopher H Aug 13 '20 at 22:00
  • @Anaoliy Tk Thanks, sudo displays the same message. By changing the owner of the folder it works. – 20f2c98f50 Aug 13 '20 at 22:06
0

It appears as though the user executing mysqldump or the user you are logged in as, does not have permissions to write the backup to the directory.

I would also change the command being used to:

mysqldump -u root -p www_example_com > /var/www/www-example-com/share/www-example-com_"`date +"%d-%m-%Y"`".sql

Reference: https://stackoverflow.com/questions/1795678/append-date-to-filename-in-linux

Christopher H
  • 338
  • 2
  • 16