List:General Discussion« Previous MessageNext Message »
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?
View as plain text  
> 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
Thread
Why the same command have different results when it is in a bashscript and when it is not?Peng Yu10 Oct
  • Re: Why the same command have different results when it is in a bash script and when it is not?Rik Wasmus10 Oct
  • Re: Why the same command have different results when it is in a bash script and when it is not?Johan De Meersman11 Oct