mySQL: repair and optimize all tables in all databases

mysqlcheck -u root -p --auto-repair --optimize --all-databases

You will be asked for root password and command will run. If you want to do it through cron, put your password immediately after -p… like -ppassword.