I'm trying to run a MySQL command from a bash script:
mysql --user=[USER] --password=[PASSWORD] --database=[DATABASE] --execute="DELETE FROM table WHERE created_at < NOW() - INTERVAL 7 DAY"
Both in the bash script and terminal, I get the same error:
ERROR 1045 (28000): Access denied for user '[USER]'@'localhost' (using password: YES)
I've tested running mysql -u [USER] -p and that will connect so I know my credentials are correct.
What am I missing? I've seen a few things online suggesting the port may be wrong, but it's all set running on localhost, which is correct
$in my password which bash is trying to interpret as a variable. Is there a way to escape the$rather than changing my password?