Archive

Archive for February, 2011

mysqldump all databases on mysql

February 20th, 2011 2 comments

I was wondering for a few minutes if I can easily backup all databases created by users on a mysql database server. I was trying to automate the process regardless of users creating new databases without my knowledge. I was aware of the convention under which mysql stores the separate databases on the filesystem so I gave it a try.
Fist I tried with few ‘ls’ commands to retrieve the folder names which respectively referred to the database names in the mysql server. On FreeBSD here is the command I used:

[root@bsdbox08 ~]# find /var/db/mysql/ -type d
/var/db/mysql/
/var/db/mysql/mysql
/var/db/mysql/db1
/var/db/mysql/performance_schema
/var/db/mysql/db2

Here I decided not to mysqldump the mysql database and the performance_schema so I changed the command slightly by adding sed and grep to it.

Read more…

Categories: Database, Linux, mysql Tags: