How to backup/Restore in mysql

Dump all databases for backup. Backup file is sql commands to recreate all db’s.

# mysqldump -u root -ppassword --opt > alldatabases.sql

Dump one database for backup.

# [mysql dir]/bin/mysqldump -u username -ppassword
 --databases databasename >/tmp/databasename.sql

Dump a table from a database.

# mysqldump -c -u username -password databasename tablename > /tablename.sql

Restore database (or database table) from backup.

# mysql -u username -password databasename < /tmp/databasename.sql

Load a CSV file into a table.

mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO
TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY
 'n' (field1,field2,field3);
Continue Reading