From: Rik Wasmus Date: October 10 2011 10:00am Subject: Re: Why the same command have different results when it is in a bash script and when it is not? List-Archive: http://lists.mysql.com/mysql/225987 Message-Id: <201110101200.00338.rik@grib.nl> MIME-Version: 1.0 Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit > 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? -- Rik Wasmus