Reputation: 1946
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
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
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
- Login to phpMyAdmin
- Click on your database name
- Click on the tab labeled EXPORT
- Select all tables you want to backup (usually all)
- Default settings usually work, just make sure SQL is checked
- Check the SAVE FILE AS box
- 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