0% found this document useful (0 votes)
84 views1 page

MySQL Database Backup and Restore Guide

This document provides instructions for exporting and importing MySQL databases and tables using the mysqldump command line tool. It describes how to export an entire database, all databases, or specific tables to SQL files. It also explains how to import SQL data files using the mysql command line tool by specifying the username, password, hostname, and database name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views1 page

MySQL Database Backup and Restore Guide

This document provides instructions for exporting and importing MySQL databases and tables using the mysqldump command line tool. It describes how to export an entire database, all databases, or specific tables to SQL files. It also explains how to import SQL data files using the mysql command line tool by specifying the username, password, hostname, and database name.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

To export

If it's an entire DB, then:


$ mysqldump -u [uname] -p[pass] db_name > db_backup.sql

If it's all DBs, then:


$ mysqldump -u [uname] -p[pass] --all-databases > all_db_backup.sql

If it's specific tables within a DB, then:


$ mysqldump -u [uname] -p[pass] db_name table1 table2 > table_backup.sql

You can even go as far as auto-compressing the output using gzip (if your DB is very big):
$ mysqldump -u [uname] -p[pass] db_name | gzip > db_backup.[Link]

If you want to do this remotely and you have the access to the server in question, then the
following would work (presuming the MySQL server is on port 3306):
$ mysqldump -P 3306 -h [ip_address] -u [uname] -p[pass] db_name > db_backup.sql

To import
Type the following command to import sql data file:
$ mysql -u username -p -h localhost DATA-BASE-NAME < [Link]

In this example, import '[Link]' file into 'blog' database using Sathish as username:
$ mysql -u sat -p -h localhost blog < [Link]

If you have a dedicated database server, replace localhost hostname with with actual server
name or IP address as follows:
$ mysql -u username -p -h [Link] databasename < [Link]

OR use hostname such as [Link]


$ mysql -u username -p -h [Link] database-name < [Link]

If you do not know the database name or database name is included in sql dump you can
try out something as follows:
$ mysql -u username -p -h [Link] < [Link]

Refer: [Link]
If you want a GUI tool then you could probably use SQLyog

You might also like