How do I connect to mysql without having to type an empty password? I just installed MySQL, and by default the root user has no password. If I connect with this command:

mysql --port=3307 --host=127.0.0.1 -uroot -p


It asks me to enter a password, I just hit return, and it connects me. However, I want to make this part of a script, by piping a statement to it non-interactively, like this:

echo "$statement" | mysql --port=3307 --host=127.0.0.1 -uroot -p


But, when I actually do that, it still asks me for the password. How do I make it NOT ask for the password, and just not use one?

I tried removing the -p, and I get this message:

$ mysql --port=3307 --host=127.0.0.1 -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


I would expect there to be some sort of --nopassword argument, but I can't find one.
Turns out the answer is actually to use the -p -- the long version allows you to set it to empty, like so:

mysql --port=3307 --host=127.0.0.1 -uroot --password=