Backing Up And Restoring Your MySQL Database
April 22nd, 2008If you’ve been using MySQL database to accumulation your essential data, it is clamant that you attain a patronage of your accumulation to preclude some expiration of data. This article shows you how to patronage and change accumulation in your MySQL database. This impact crapper also be utilised if you hit to advise your accumulation to a newborn server.
Backing up your database
The quickest and easiest artefact to patronage and change your database would be to ingest MySQLDump. If you’ve got bomb or telnet admittance to your server, you crapper patronage MySQL accumulation by supply the mysqldump command. The structure for the bidding is as follows.
mysqldump -u [uname] -p [pass] [dbname] > [backupfile.sql] [uname] - this is your database username [pass]- this is the countersign for your database [dbname] - the study of your database [backupfile.sql] - the name for your database backup
To patronage your database ‘Customers’ with the username ’sadmin’ and countersign ‘pass21′ to a enter custback.sql, you would supply the command
mysqldump -u sadmin -p pass21 Customers > custback.sql
Issuing this bidding module patronage the database to custback.sql. This enter crapper be derived to a innocuous positioning or a patronage media and stored. For more aggregation on MySQLDump, you crapper analyse discover : http://www.mysql.com/doc/en/mysqldump.html
Restoring your database
If you hit to re-build your database from scratch, you crapper easily change the mysqldump enter by supply the mass command. This method module not impact if the tables already subsist in your database.
mysql - u sadmin -p pass21 Customers < custback.sql
If you requirement to change existing databases, you’ll requirement to ingest MySQLImport. The structure for mysqlimport is
mysqlimport [options] database textfile1
To change your previously created custback.sql shitting backwards to your Customers Database, you’d issue
mysqlimport -u sadmin -p pass21 Customers custback.sql
For more aggregation on MySQLImport, you crapper analyse discover : http://www.mysql.com/doc/en/mysqlimport.html
About The Author
Vinu saint is a consultant on Webdesign and cyberspace Technologies. His website is http://www.vinuthomas.com. You crapper handle most this article or some PHP/MYSQL attendant issues in our Discussion Forums: http://www.vinuthomas.com/forum2.html
Tags: backups, data recovery, databases, db, dbms, disaster recovery, Mysql, sql, SQL code