M
M
Mikhail Vasiltsev2018-07-22 22:22:29
Task Schedulers
Mikhail Vasiltsev, 2018-07-22 22:22:29

How to write a command in the crown to create an sql dump of the database in the right folder?

Greetings. The bottom line is, there is a command:

mysqldump -u user -p dbname > /path/to-filder/dump.sql

When I execute it simply in the terminal, it asks for a password, I enter it and the database dump is created in the desired folder. But when I cram it into cron, it doesn’t work, as I understand it, because the second step is to enter a password.
On the internet, I found the following variants of this command:
mysqldump --opt -u user -p pass dbname > /path/to-folder/dump.sql
mysqldump --opt -u user dbname -p pass > /path/to-folder/dump.sql

I tried to shove them one by one into the cron - an empty dump is created.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2018-07-23
@mihail430899

Remove the space between -p and the password.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question