Mysql with shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mysql with shell script
# 1  
Old 09-03-2008
Mysql with shell script

Hi

did any books teaching beginner to run mysql using BASH shell?

thkx
# 2  
Old 09-03-2008
what exactly you wanna learn??
because if you know how to connect to mysql from unix command prompt its all needed
rest is simple..
# 3  
Old 09-03-2008
just wanted to learn the way they code.

thkx
# 4  
Old 09-03-2008
here is a shell script to show contents of a mysql table.

Code:
TABLE_NAME=sometable
USER_NAME=someuser
IP_ADDR=localhost
PASSWORD=somepassword

somevar=`echo "select * from <table_name> where <condition>" | mysql -h $IP_ADDR -u $USER_NAME -p$PASSWD $TABLE_NAME `

echo $somevar

# 5  
Old 09-03-2008
My fault

<< eof

eof
# 6  
Old 09-03-2008
Quote:
Originally Posted by Ikon
here is a shell script to show contents of a mysql table.

Code:
TABLE_NAME=sometable
USER_NAME=someuser
IP_ADDR=localhost
PASSWORD=somepassword

somevar=`echo "select * from <table_name> where <condition>" | mysql -h $IP_ADDR -u $USER_NAME -p$PASSWD $TABLE_NAME `

echo $somevar

Hi Ikon
Thanks for sharing
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mysql is not working in shell script

Hi Team, I have created attached script in mysql environment. But there is below error . can you please suggest . Error : Unknown table 'processlist' in finformation_schema #!/bin/bash mysql -u $DBUSER -p$DBPASS -e " select -- * id from information_schema.processlist where... (1 Reply)
Discussion started by: Jewel
1 Replies

2. Shell Programming and Scripting

Need help on Insert data to phpMyAdmin mySQL database from Shell Script

Sorry to disturb you, I would like to seek help on inserting data whenever the switch is on or off to my phpMyAdmin mySQL database from my Shell Script. I'm using Raspberry PI as my hardware and I have follow this LINK: instructables.com/id/Web-Control-of-Raspberry-Pi-GPIO/?ALLSTEPS to create my... (4 Replies)
Discussion started by: aoiregion
4 Replies

3. Shell Programming and Scripting

Shell script - Download - Mysql replace

Hi, I have a video script. it has embedded Youtube videos. I want replace them downloaded version mp4 videos. this script has a mysql table. I want search "url_flv" field on table a youtube link if has a youtube link I want download it this command. I want extract uniq_id field for file... (2 Replies)
Discussion started by: tara123
2 Replies

4. Shell Programming and Scripting

mysql script in a command shell

Hi can anyone help with my issue here. I new in linux and new in scripting. i was ask to do the following below and i`m getting errors. I managed to create the table and the database. Now i need to add the details in a shell to update the database.... (7 Replies)
Discussion started by: mduduzi
7 Replies

5. Shell Programming and Scripting

mysql script in a command shell

Hi i`m trying this script to run and i get the following error. Enter your name tman Enter your surname smith -bash: ./500: line 20: unexpected EOF while looking for matching `"' -bash: ./500: line 21: syntax error: unexpected end of file ... (2 Replies)
Discussion started by: mduduzi
2 Replies

6. Shell Programming and Scripting

Using a shell script variable in a mysql query using 'LIKE'

Hello. I am writing a simple script that reads a text file and removes records from a mysql database. The items in the text file are of the format: firstname.middle.lastXXX, where XXX is a 3 digit number. The table has an email field that will match the firstname.middle.last. So, I thought I... (1 Reply)
Discussion started by: bricoleur
1 Replies

7. Shell Programming and Scripting

How to get and process mysql result set in shell script

Hi All, I am in a problem here is the description, Actually in my shell script i am firing a mysql query which returns multiple records and i have to process each record one by one. So could any one please suggest me how to solve my problem? Thanks in Advance Ashok Sharma (4 Replies)
Discussion started by: ashok1979
4 Replies

8. Shell Programming and Scripting

Passing a variable from shell script to mysql query?

I heard this was possible but from my research I haven't been able to figure it out yet. Seems it should be simple enough. Basically from a high level view I'm trying to accomplish... . $X='grep foo blah.log' then 'mysql command SELECT foo FROM bar WHERE ' . $X or something like that. ... (2 Replies)
Discussion started by: kero
2 Replies

9. Shell Programming and Scripting

Multiple MySql queries in shell script?

Hi guys, i know how to run a single query using mysql embedded in a shell script as follows: `mysql -umyuser -pmypass --host myhost database<<SQL ${query}; quit SQL` However, how would i be able to run several queries within the same connection? The reason for this is i am creating... (3 Replies)
Discussion started by: muay_tb
3 Replies

10. Shell Programming and Scripting

executing mysql load statement from shell script

Hi, I have a piece of shell script which will connect to mysql database and execute a load statement(which will load datas in a file to the database table).The code is working and the data is in the tables. Now my requirement is, i need to grab the output from the load statement... (4 Replies)
Discussion started by: DILEEP410
4 Replies
Login or Register to Ask a Question