0

i have try to set cron file for get auto backup to all my database table.

i was using following mysqldump command :

sudo mysqldump -u username -p password --all-databases | gzip > mysqldb_`date +%F`.sql.gz

but it's show following error :

mysqldump: Got error: 1049: Unknown database 'password' when selecting the database

any other option to get automatic mysql database backup

thank you...

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Sujal Patel
  • 592
  • 2
  • 5
  • 14

2 Answers2

0

Try this:

sudo mysqldump -u root -p<mysql-password> --all-databases | gzip > mysqldb_date +%F.sql.gz
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59
  • add space between -p and – Sujal Patel Dec 27 '16 at 10:09
  • it's not show the error but generated file content in mysqldump command list `Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR mysqldump [OPTIONS] --all-databases [OPTIONS] For more options, use mysqldump --help` – Sujal Patel Dec 27 '16 at 10:52
0

From docs (emphasis mine):

--password[=password], -p[password]

The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysql prompts for one.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • i was enter password without space it's given following error: gzip: +%F.sql.gz: No such file or directory Warning: Using a password on the command line interface can be insecure. – Sujal Patel Dec 27 '16 at 10:13
  • I cannot reproduce the first message (second one is self-explanatory) but you should probably store the file in some specific path, not in whatever working directory the scripts happens to run at. – Álvaro González Dec 27 '16 at 10:18
  • command run successfully it's not show any error but generated file show follwoinig text Usage: mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR mysqldump [OPTIONS] --all-databases [OPTIONS] For more options, use mysqldump --help – Sujal Patel Dec 27 '16 at 10:21