PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > getting a list of all databases in a comma delineated format?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
getting a list of all databases in a comma delineated format?

Réponse
 
LinkBack Outils de la discussion
Vieux 05/11/2007, 19h33   #1
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut getting a list of all databases in a comma delineated format?

I'm trying to write a batch file that'll backup all my databases and
had a question. I was thinking about executing SHOW Databases to get
a list of all the databases and then use mysqldump on each one. To do
this, I was thinking I'd use for loops as described at <http://
www.robvanderwoude.com/for.html>. The only problem is that these for
loops require you use a comma / space / semicolon delineated list.

Here's the command I'm using to get the list of databases:

mysql -u username -ppassword --execute="SHOW Databases"

Here's what it returns:

+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
| whatever else |
+--------------------+

That's not all that ful. Is there any way to get the list to
output in the required format?

  Réponse avec citation
Vieux 05/11/2007, 19h44   #2
J.O. Aho
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: getting a list of all databases in a comma delineated format?

yawnmoth wrote:

> +--------------------+
> | Database |
> +--------------------+
> | information_schema |
> | test |
> | whatever else |
> +--------------------+
>
> That's not all that ful. Is there any way to get the list to
> output in the required format?
>

You could use awk to transform the outdata to what you want it to be. There
are quite many resources how to use awk.



--

//Aho
  Réponse avec citation
Vieux 05/11/2007, 19h55   #3
Radoulov, Dimitre
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: getting a list of all databases in a comma delineated format?

yawnmoth wrote:
> I'm trying to write a batch file that'll backup all my databases and
> had a question. I was thinking about executing SHOW Databases to get
> a list of all the databases and then use mysqldump on each one.

[...]

What's the problem with:

mysqldump --all-databases ...

If you want to select a few:

mysqldump -d $(mysql -NBe "show databases like '%pattern%'")


Dimitre
  Réponse avec citation
Vieux 05/11/2007, 20h01   #4
yawnmoth
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: getting a list of all databases in a comma delineated format?

On Nov 5, 1:55 pm, "Radoulov, Dimitre" <cichomit...@gmail.com> wrote:
> yawnmoth wrote:
> > I'm trying to write a batch file that'll backup all my databases and
> > had a question. I was thinking about executing SHOW Databases to get
> > a list of all the databases and then use mysqldump on each one.

>
> [...]
>
> What's the problem with:
>
> mysqldump --all-databases ...
>
> If you want to select a few:
>
> mysqldump -d $(mysql -NBe "show databases like '%pattern%'")
>
> Dimitre


I didn't know about that, heh. Thanks!

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h59.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10479 seconds with 12 queries