Restoring MySQL dump files

Moderator: cah

Post Reply
cah
General of the Army / Fleet Admiral / General of the Air Force
General of the Army / Fleet Admiral / General of the Air Force
Posts: 1342
Joined: Sun Aug 17, 2008 5:05 am

Restoring MySQL dump files

Post by cah »

I created a backup script to backup MySQL DB schemas some time ago.

I was playing with phpBB3 and accidentally deleted a post.
I then tried to get the post back, of course.

Fortunately, I have MySQL schemas backed up daily.
I found last night(this morning)'s backup and just needed to restore it.

Here is the command I issued:

Code: Select all

Syntax:

<PATH>/mysql -u<USER> -p <DB Name> < <SQL dump file>

Code: Select all

/usr/local/bin/mysql -udbuser -p phpBB3 < ./phpBB3-backup-20081203053506.sql
NOTICE wrote:
  1. DB user (dbuser) comes directly after "-u", no space in between.
  2. -p means the command will ask for user's password from command line.
  3. phpBB3 is the database (schema).
  4. MySQL dump file (phpBB3-backup-20081203053506.sql) is read into MySQL and all files are put into right place.
CAH, The Great
Post Reply