terrid25
terrid25

Reputation: 1946

backing up/copying mysql database

I have a DB which is a live one, what I'm looking to do, is to make a copy. I have access to MySQl via SSH and phpMyAdmin. Is there a command where I can copy/backup the DB, in a single command/action, without using export/import?

Thanks

Upvotes: 0

Views: 177

Answers (2)

terrid25
terrid25

Reputation: 1946

Ok, so I found a command that would take a dump of one database and then insert it into another DB using a single command:

mysqldump -u username -ppassword live_db | mysql -u username -ppassword backup_db

Upvotes: 0

Nishant
Nishant

Reputation: 55866

        mysqldump -u USERNAME -pPASSWORD databaseName > SAVETOFILE.sql

see this http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html for various options available.

you can do via PHPMyAdmin as well see here http://php.about.com/od/learnmysql/ss/mysql_backup_3.htm

  1. Login to phpMyAdmin
  2. Click on your database name
  3. Click on the tab labeled EXPORT
  4. Select all tables you want to backup (usually all)
  5. Default settings usually work, just make sure SQL is checked
  6. Check the SAVE FILE AS box
  7. Hit GO

If you want to create DB that is a copy of above sqldump you need to do run the following command

 mysql -u USERNAME -pPASSWORD < SAVEDFILE.sql

But, I feel you are looking for something like replication. In that case you need to set-up master-slave configuration where data gets replicated on slave. See this guide for replication

http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html

Upvotes: 1

Related Questions