From: Tzafrir Cohen on
On Wed, Apr 21, 2010 at 02:27:47PM +0530, Siju George wrote:
> On Wed, Apr 21, 2010 at 2:16 PM, Mart Frauenlob
> <mart.frauenlob(a)chello.at> wrote:
> >
> > how about:
> > ... -p 'my$qlPW' -N ...
> >
>
> # `mysql -u root -p 'my$qlPW' -N -B -e 'show databases'`
> Enter password:
>
> asks for PW
>
> # `mysql -u root -p'my$qlPW' -N -B -e 'show databases'`
> -bash: information_schema: command not found

You got the output of 'show databases'. You then consider it a shell
command and try to excute it. Why would you want to do that? What do you
want to do with that output?

BTW: I would suggest that you actually use a .my.cnf to hold the
password, otherwise the password is available in e.g. the output of 'ps
auxww'

--
Tzafrir Cohen | tzafrir(a)jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir(a)cohens.org.il | | best
tzafrir(a)debian.org | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/20100421090133.GV16560(a)pear.tzafrir.org.il
From: Mart Frauenlob on
On 21.04.2010 10:57, Siju George wrote:
> On Wed, Apr 21, 2010 at 2:16 PM, Mart Frauenlob
> <mart.frauenlob(a)chello.at> wrote:
>>
>
> # `mysql -u root -p'my$qlPW' -N -B -e 'show databases'`
> -bash: information_schema: command not found

there we go...
now, i guess u want to save the output of the command into a variable right?
foo="`mysql -u root -p'my$qlPW' -N -B -e 'show databases'`"

whatever that's good for...
don't forget your root password isn't save at all here....


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/4BCEC027.7090806(a)chello.at
From: Siju George on
On Wed, Apr 21, 2010 at 2:31 PM, Tzafrir Cohen <tzafrir(a)cohens.org.il> wrote:
>
> You got the output of 'show databases'. You then consider it a shell
> command and try to excute it. Why would you want to do that? What do you
> want to do with that output?
>

mysql -u root -pmy\$ql -N -B -e 'show databases'

works

I was to get the script

#!/bin/sh
for DB in `mysql -u root -pmy\$qlPW -N -B -e 'show databases'`; \
do echo $DB; \
mysqldump -u root -pmy\$qlPW -e $DB > /var/mysql-1hBak/$DB.sql; \
done

to work.

> BTW: I would suggest that you actually use a .my.cnf to hold the
> password, otherwise the password is available in e.g. the output of 'ps
> auxww'
>

yes I would eventually do that but even then you need to escape the $ inside ``

thanks

--Siju


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/v2lb713df2c1004210210pd0c85744o2d1e9573ec13cae(a)mail.gmail.com
From: Mart Frauenlob on
On 21.04.2010 11:10, Siju George wrote:
[...]
>
> I was to get the script
>
> #!/bin/sh
> for DB in `mysql -u root -pmy\$qlPW -N -B -e 'show databases'`; \
> do echo $DB; \
> mysqldump -u root -pmy\$qlPW -e $DB > /var/mysql-1hBak/$DB.sql; \
> done
>
> to work.
>
>> BTW: I would suggest that you actually use a .my.cnf to hold the
>> password, otherwise the password is available in e.g. the output of 'ps
>> auxww'
>>
>
> yes I would eventually do that but even then you need to escape the $ inside ``
>

mysql .... | while read; do
mysqldump -e "$REPLY" > ...
done



--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/4BCEC253.70704(a)chello.at
From: Tzafrir Cohen on
On Wed, Apr 21, 2010 at 02:40:54PM +0530, Siju George wrote:
> On Wed, Apr 21, 2010 at 2:31 PM, Tzafrir Cohen <tzafrir(a)cohens.org.il> wrote:
> >
> > You got the output of 'show databases'. You then consider it a shell
> > command and try to excute it. Why would you want to do that? What do you
> > want to do with that output?
> >
>
> mysql -u root -pmy\$ql -N -B -e 'show databases'
>
> works
>
> I was to get the script
>
> #!/bin/sh
> for DB in `mysql -u root -pmy\$qlPW -N -B -e 'show databases'`; \
> do echo $DB; \
> mysqldump -u root -pmy\$qlPW -e $DB > /var/mysql-1hBak/$DB.sql; \

mysqldump --all-databases ?

> done

$ mysql mysql -e 'show databases'
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test123 |
+--------------------+

$ mysql mysql --batch -e 'show databases'
Database
information_schema
mysql
test123

$ mysql mysql --batch --silent -e 'show databases'
information_schema
mysql
test123

>
> to work.
>
> > BTW: I would suggest that you actually use a .my.cnf to hold the
> > password, otherwise the password is available in e.g. the output of 'ps
> > auxww'
> >
>
> yes I would eventually do that but even then you need to escape the $ inside ``

In that case, the '$' is not part of the command-line, and hence no need
to escape it.

--
Tzafrir Cohen | tzafrir(a)jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir(a)cohens.org.il | | best
tzafrir(a)debian.org | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/20100421092540.GW16560(a)pear.tzafrir.org.il