LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-22-2005, 03:52 AM   #1
sumitarun
LQ Newbie
 
Registered: Mar 2005
Posts: 8

Rep: Reputation: 0
Database connection using Shell Script


Hi,

I am new to red Hat Linux.. In my project there is a requirement where i need to connect to a Database in MySql, kept on another machine using shell scripting.

Can any provide help in this?
 
Old 03-22-2005, 08:36 AM   #2
ctjohns
LQ Newbie
 
Registered: Mar 2005
Posts: 2

Rep: Reputation: 0
Hello,

You can use the following to connect to a mysql database:

DBUSER=which ever user mysql is ran under
DBPASSWORD=database password
DBDATABASE=databas name

command=`mysql -B -D $DBDATABASE -u $DBUSER -p$DBPASSWORD -e "database commands`

print $command


you can do watever you want with the variable command. Also the sql statement does not need to be put into a variable it can just be ran as a command.

The other way to log on would be to simply type:

mysql -p

There would be no need for a script then.

Thanks
Craig
 
Old 05-09-2010, 01:18 PM   #3
ashubalike
LQ Newbie
 
Registered: Feb 2010
Posts: 1

Rep: Reputation: 0
Database connectivity

tHIS BECOME VERY MUCH USEFUL FOR ME IN PROGRAMMING.
THANKS A LOT.

Quote:
Originally Posted by ctjohns View Post
Hello,

You can use the following to connect to a mysql database:

DBUSER=which ever user mysql is ran under
DBPASSWORD=database password
DBDATABASE=databas name

command=`mysql -B -D $DBDATABASE -u $DBUSER -p$DBPASSWORD -e "database commands`

print $command


you can do watever you want with the variable command. Also the sql statement does not need to be put into a variable it can just be ran as a command.

The other way to log on would be to simply type:

mysql -p

There would be no need for a script then.

Thanks
Craig
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
my database export shell script run from command line but not form crontab saifee Linux - General 11 01-29-2012 10:24 AM
How to compare records in two tables in seperate My Sql database using shell script sumitarun Programming 5 04-14-2005 10:45 AM
MySQL connection in shell script - how to? philipz Programming 3 04-29-2004 08:04 PM
Import records to MySQL Database from a shell script chrisk5527 Linux - General 12 03-24-2004 10:49 PM
How to Shell Script auto ftp connection? mtn356 Linux - General 4 03-18-2004 08:31 PM


All times are GMT -5. The time now is 08:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration