Re: Why the same command have different results when it is in a bash script and when it is not?
I don't have a direct answer for you, just some thoughts: * traditionally, "localhost" is thought of as an alias for 127.0.0.1 * mysql however, tends to not interpret it like when connecting to the local server and instead tries to connect to the socket * to force mysql client to connect over tcp/ip instead, use -h 127.0.0.1 It's possible that the execution environment of a script is subtly different and causes the client to interpret it the other way, but I've no idea what the exact difference would be. - Original Message - > From: "Peng Yu" > To: mysql@lists.mysql.com > Sent: Monday, 10 October, 2011 12:19:20 AM > Subject: Why the same command have different results when it is in a bash > script and when it is not? > > Hi, > > 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. > Your MySQL connection id is 101 > Server version: 5.5.9 Source distribution > > Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights > reserved. > > Oracle is a registered trademark of Oracle Corporation and/or its > affiliates. Other names may be trademarks of their respective > owners. > > Type 'help;' or '\h' for help. Type '\c' to clear the current input > statement. > > mysql> > -- Bier met grenadyn Is als mosterd by den wyn Sy die't drinkt, is eene kwezel Hy die't drinkt, is ras een ezel -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: Why the same command have different results when it is in a bash script and when it is not?
> 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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Why the same command have different results when it is in a bash script and when it is not?
Hi, 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. Your MySQL connection id is 101 Server version: 5.5.9 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> -- Regards, Peng -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org