Log in

View Full Version : Backing up the database


Lodan
02-13-2003, 09:44 AM
Can anyone tell me how I can easily backup the database before I make changes.

Thanks

eqfoobar
02-13-2003, 11:35 AM
Go to the mysql\bin directory from a command prompt window.

Type mysqldump <put your database name here> > somefilenameyoulike.SQL

Example. If my database was named eq and the file I wanted it put in was myeqdatabase.sql - I would type:

mysqldump eq > myeqdatabase.sql

(note:check the file and make sure the contents are there and not some error text).

To restore it, you would go into a mysql prompt.
Drop your existing database with: drop database <yourdatabasename>;

Create the database again: create database <yourdatabasename>;

and then source the database with your file...
use <yourdatabasename>;
source <path to somenameyoulike.sql>somenameyoulike.sql

Note, you can always restore it to a newly created database and change your db.ini file to point to the newly created database allowing you to experiment with multiple databases.

For more help, check the mysql documentation on these commands.

- foobar

Lodan
02-13-2003, 09:27 PM
Thanks for that.
I'll give it a go over the wekend.

IACryogenic
02-14-2003, 10:35 AM
If i was to ammend the database in any way would i need to remove the old one first ?

DeletedUser
02-14-2003, 10:46 AM
I would remove any filename you are about to export to before you export to it.