I am trying to set up a cron job that everyday optmizes the mysql database using debian on a virtual machine.
First I have tried using the mysqlcheck like this:
0 * * * * mysqlcheck -Aao –auto-repair -u root -p[password] > /dev/null
I got this error: mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect
after googling this error I found Dave Stoddard Comment who was experiencing the same problem:
0 * * * * /usr/local/bin/mysqlcheck --defaults-file=/root/.my.cnf --all-databases --auto-repair 2>&1 | grep -v "OK" | mail -s "Database Problem" root
or 0 * * * * /usr/local/bin/mysqlcheck --defaults-file=/root/.my.cnf --all-databases --auto-repair 2>&1 | grep -v "OK" | mail -s "Database Problem" root
Error from above:
/bin/sh: root: command not found
/bin/sh: /usr/local/bin/mysqlcheck: No such file or directory