Linux, Apache, PHP, MySQL Administrators Forums

Go Back   Linux, Apache, PHP, MySQL Administrators Forums > LAMP Forums > MySQL

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-18-2009, 11:43 AM
Junior Member
 
Join Date: Feb 2009
Posts: 9
Talking List Databases from shell script

hello again guys

I need a little help with a bash script I am trying to make o backup our databases. What I need is to list all databases from my MySQL server and with that resulting list I can loop through and backup each database directory .

I know its easy for the gurus, but I can login to mysql server from my script but its not listing properly to loop thru

TIA
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-18-2009, 01:56 PM
Administrator
 
Join Date: Jan 2009
Posts: 40
Lightbulb

Code:
DBS=`echo "show databases;" | mysql -u root -pmypassword | tail -n +2`
I think this is what you need, $DBS will contain a list you can loop through and do you stuff.

HTH
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-20-2009, 06:53 PM
Junior Member
 
Join Date: Feb 2009
Posts: 9
Thumbs up

as always, thanks swordfish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-16-2009, 11:45 AM
Junior Member
 
Join Date: Apr 2009
Posts: 1
Default anohter one

Quote:
Originally Posted by swordfish View Post
Code:
DBS=`echo "show databases;" | mysql -u root -pmypassword | tail -n +2`
I think this is what you need, $DBS will contain a list you can loop through and do you stuff.

HTH
Or use this one

Code:
DBS=`mysql -u root -pmypassword -e 'show databases' | tail -n +2`
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-16-2009, 12:02 PM
Administrator
 
Join Date: Jan 2009
Posts: 40
Thumbs up

Quote:
Originally Posted by wcervini View Post
Or use this one

Code:
DBS=`mysql -u root -pmypassword -e 'show databases' | tail -n +2`
Another neat way to do it wcervini

BTW, welcome aboard!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:36 AM.


Community hosted with DotManila Consulting
Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2