Page 1 of 1

backing up SQL database

Posted: Mon Aug 08, 2005 2:10 pm
by psychotomus
Anyone got any simple code that will back up a SQL database. I could do it myself. First I would need to know how to get all the TABLES from the database with all of there fields. I can then grab all the contents from the table by myself with a select statement.

So how can I grab all the tables from a database and there fields?

Posted: Mon Aug 08, 2005 2:35 pm
by pickle
Do you have access to the command line? If so you can use mysqldump to get a dump file.

If not, do you have phpmyadmin? That can make a dump file too.

If you have none of that, you will, of course, have to do it manually. The first step would be to call a query "show tables". Then, loop through each table calling a query "SHOW CREATE TABLE [table name]" That will output the query needed to recreate [table name]. You can then go through and read in each row into a CSV.

Do try to find a way to make/get a mysqldump file - it's much much much easier.

Posted: Mon Aug 08, 2005 3:11 pm
by feyd
this topic has been talked about a lot.. some recently..

Moving to Databases