Note that there are some explanatory texts on larger screens.

plurals
  1. POMysqldump without password in crontab
    text
    copied!<p>I try to backup my database with mysqldump and cronjobs.</p> <p>Well, I added the following command to the crontab of user root:</p> <pre><code>*/30 * * * * mysqldump -u root -pVERYSECUREPASSWORD --all-databases &gt; /var/www/cloud/dump_komplett.sql &amp;&gt; /dev/null </code></pre> <p>This works fine so far, but the problem is that the password is set in this command.</p> <p>So I want to include a .database.cnf file that look like this</p> <pre><code>[mysqldump] user=root password=VERYSECUREPASSWORD </code></pre> <p>and changed the mysqldump command to</p> <pre><code>mysqldump --defaults-extra-file="/var/crons/mysql/.database.cnf" --all-databases -u root &gt; /var/www/cloud/dump_komplett.sql </code></pre> <p>to solve this problem.</p> <p>But this command fails with the error:</p> <pre><code>mysqldump: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect </code></pre> <p>I don't know what's wrong.</p> <p>Here are some commands I also tried:</p> <pre><code>mysqldump --defaults-extra-file="/var/crons/mysql/.database.cnf" --all-databases &gt; /var/www/cloud/dump_komplett.sql mysqldump --defaults-file="/var/crons/mysql/.database.cnf" --all-databases &gt; /var/www/cloud/dump_komplett.sql mysqldump --defaults-file="/var/crons/mysql/.database.cnf" --all-databases -u root &gt; /var/www/cloud/dump_komplett.sql </code></pre> <p>and .database.cnf contents I also tried:</p> <pre><code>[client] user=root password=VERYSECUREPASSWORD [mysqldump] host=localhost user=root password=VERYSECUREPASSWORD [client] host=localhost user=root password=VERYSECUREPASSWORD </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload