Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am making script to backup users home directories and databases. i can make backup by going through dirs but i am not able to find a way to gets databases belong to particular user

share|improve this question

migrated from May 23 '11 at 1:05

This question came from our site for professional and enthusiast programmers.

Databases don't belong to users in MySQL. – Ignacio Vazquez-Abrams May 21 '11 at 15:45
Are you talking about Linux users or MySQL users? Are you backing up in SQL format or hot-copying the database dirs? – Benjamin Morel May 21 '11 at 15:46
Are the database usernames the same as the home directories? – mhitza May 21 '11 at 15:48
yes db users same as home dirs and DB names start with username_something – Mirror51 May 21 '11 at 15:53
up vote 1 down vote accepted

If you plan to use mysqldump, which doesn't support wildcards in database names AFAIK, you could first from your Python script issue a SHOW DATABASES query, which will return all database names.

Then group them by user name, and call mysqldump with the --databases option based on the result of your script.

There may be simpler, turnkey solutions however.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.