Mike Nguyen
Mike Nguyen

Reputation: 17

MySQL data backup?

I have an database with tons of data in it. I also wrote a new program that will change the data in the database. Is there any way to make a copy of the database before i run my program? Or is there any other solution?

What I'm thiking is making a copy of the database, Run the program, which modified the main database. If things goes wrong, how do I use my copied database data to revert the main database?

Please provide steps and commands on linux. I'm new with the database mysql and its commands.

Upvotes: 0

Views: 44

Answers (3)

Amit Garg
Amit Garg

Reputation: 1228

Read the following link this will tell you how to dump your database via different ways and restore it.

http://www.thegeekstuff.com/2008/09/backup-and-restore-mysql-database-using-mysqldump/

Basic command to dump a single database is:
mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

Upvotes: 0

0xtvarun
0xtvarun

Reputation: 698

You can use the mysqldump command to make a backup of your database and overwrite the backup file everytime

mysqldump -u <user> -p <db> > dump.sql

Upvotes: 1

Victor Hugo Montes
Victor Hugo Montes

Reputation: 1322

Is there any way to make a copy of the database before i run my program?

Yes, there's. You have to use the client utility mysqldump before run you app.

It is something like

shell> mysqldump [options] > dump.sql

Upvotes: 0

Related Questions