I want to log in to a database by running a SQL file from a UNIX script without supplying username and password (as root). Any command to do so?
closed as too localized by Marco Ceppi♦ Dec 6 '11 at 12:38
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
You can store the username and password do use in ~/.my.cnf
But this file is unencrypted so beware of that.
Many client softwares - including mysql - can get passwords from command line. Try
Where ROOT_PASSWORD is password for mysql root account. You can also use certificates for logins.
As there is some confusion, at least recent versions of mysql are masking your password from process listing. You can check this by running above mentioned command and then in another terminal
If you see something like