Thursday, October 23, 2008

mysql dump and restore a single table.

Dumping or backing up a table:

mysqldump -u username -ppassword --default-character-set = latin1 --single-transaction database --tables table > /location/table_bk.sql


Restoring a backed up sql.

mysql -u username -ppassword database < /location/table_bk.sql

Wednesday, October 8, 2008

Mysql Backup a single table from the database

and to restore a specific table from the database:

mysqldump -u readonly -preadonly --single-transaction db_name --tables table_name > dir/sql/name

This really worked well for me and will do for you as well...:~))

Backup and restore mysql data....Example.

The example I was taught goes simply like this:

mysql>mysqldump -u root -p DATABASENAME > DATABASENAME.sql

If you wanted to test it, you could drop the database:

mysql>DROP DATABASE DATABASENAME;
(DATABASE referring to DATABASENAME, the one you just backed up)

The quit mysql:

mysql>q

Log back in:

]$ mysql -u root -p
mysql>CREATE DATABASE PREVIOUS_DATABASENAME;
mysql> \q
Bye
]$ mysql -u root -p PREVIOUS_DATABASENAME < DATABASENAME.sql
Enter password:


And it will be restored!


 
Custom Search