Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy and overwrite one database into another using mysql

I want to copy my production database to my development environment. I copied website_production into mysql of my developemnt environment, so using SHOW DATABASES; now I have

website_development website_production

as databases. How can I copy and overwrite all tables with their content from website_production into website_developemnt using mysql commands?

like image 361
user929062 Avatar asked Apr 22 '13 11:04

user929062


People also ask

How do I overwrite an existing MySQL database?

What you can do is log in to MySQL and drop the tables that you plan to overwrite, then use --force on import.


Video Answer


1 Answers

It's not MySQL commands but it's the easiest method, from command line:

$ mysqldump -u user --password=pass live_db_name | mysql -u user --password=pass -h localhost duplicate_db_name

Works on Windows terminal too.

like image 179
Glitch Desire Avatar answered Oct 21 '22 19:10

Glitch Desire