Friday, August 17, 2012

How to take a backup and restore a mysql database

•    Take a full backup of the database:

             mysqldump [db_name] > /location(tmp)/db_name_bak.sql

•    Move the backup file to the appropriate location or to the destination server: use winscp

•    Restore the database after taking a precaution backup:

      mysql cust_support < /tmp/cust_sup.sql > /home/mysql/log.txt

Verification:  Run this script on the both databases and see the result

    SELECT table_schema "Data Base Name",
        sum( data_length + index_length ) / 1024 / 1024 "Data Base 
             Size in MB",
               sum( data_free )/ 1024 / 1024 "Free Space in MB"
               FROM information_schema.TABLES
              WHERE table_schema = 'cust_support'
         GROUP BY table_schema ;

In depth:

Login to your Linux server with your windows authentication.
   sudo su –
   su mysql
   @bash run the mysqldump command






















.

No comments:

Post a Comment