> It is seems strange to me why the same command "mysql -hlocalhost
> -uxxx" when it is run from the command line, it will show an error.
> When it is run in a bash script, it runs fine. I guess this might be
> described somewhere, but I'm yet to find the answer. Does anybody know
> why this happens and how to make the command line version working?
> ~$ mysql -hlocalhost -uxxx
> ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using
> password: YES)
> ~$ cat `which mysqllocalhostxxx.sh `
> #!/usr/bin/env bash
> mysql -hlocalhost -uxxx
> ~$ mysqllocalhostxxx.sh
> Welcome to the MySQL monitor. Commands end with ; or \g.
What does 'which mysql' give you? Is it perhaps in 'alias -p'? And is there
perhaps a .my.cnf file in your users directory?