Using Shell Scripting,accessing MySQL

Using Shell Scripting,accessing MySQL

Post by guna.. » Sun, 25 Jun 2006 14:03:51



Hi'

I'm trying to write a shell script to log into MySQL, chose the correct
database and run MySQL's \. command.

The problem is that i am able to login into the mysql, but i am not
able to run the MySQL's command.

can any one please help me in this.

Regards,
F Joe Gladston

 
 
 

Using Shell Scripting,accessing MySQL

Post by Noel » Sun, 25 Jun 2006 19:06:25


Hello,

Did you try with a script like :

mysql -u user <<END
use mybase;
select * from mytable;
exit;
END



Quote:> Hi'

> I'm trying to write a shell script to log into MySQL, chose the correct
> database and run MySQL's \. command.

> The problem is that i am able to login into the mysql, but i am not
> able to run the MySQL's command.

> can any one please help me in this.

> Regards,
> F Joe Gladston


 
 
 

Using Shell Scripting,accessing MySQL

Post by Radoulov, Dimitr » Sun, 25 Jun 2006 21:39:58


Quote:> I'm trying to write a shell script to log into MySQL, chose the correct
> database and run MySQL's \. command.

> The problem is that i am able to login into the mysql, but i am not
> able to run the MySQL's command.

> can any one please help me in this.

$ mysql -u root -D mysql -B -N -e "select user from user limit 1;"
root

For more options check mysql -?.

Regards
Dimitre

 
 
 

1. using MySQL's encrypt() function in a shell script

Hello,

I am setting up a Postfix + MySQL + Courier-IMAP system.  I am trying
to write a shell script which will insert the values into the
database.  For the password encryption, I wish to use MySQL's
encrypt() function.  Thisis what I have in my script:

echo "INSERT INTO users(id,address,crypt,clear,name,domain,maildir)" >
/tmp/insert.sql
$name','$domain','$userDir/Maildir')"
mysql -h $dbhost -u $dbuser -p$dbpass $dbname < /tmp/insert.sql

Assuming that the value of $password is "password", instead of the
encrypted version of "password", I get the following in the "crypt"
field:

encrypt('password')

I believe this has something to do with the use of the single quotes
around 'encrypt('$password')', but I do not know how to work around
that.

Does anyone have any ideas on how to do this?

TIA for your help.


2. source safe

3. Accessing a shell script w/o doing . /script

4. Ok, I give up

5. using born shell script as login shell?

6. pdksh on freebsd is el-lame-o

7. Newbie help with Shell scripts (using Korn shell)

8. NIC speed setting

9. Copy files using filenames from text files with shell script or bash script

10. shell script using another script

11. Problems with a MySQL Backup Shell Script

12. Input into mySQL through shell script?

13. Using MyODBC client to access MySQL on RedHat 7