Copy a database in MySQL. Here's How.
January 28, 2019
Here's how to copy a database in MySQL from the command line. It's really simple. I needed to do this today and the following instructions did what they should.
In my example, I have a database named olddatabase that I wish to copy. I will copy all of the tables and rows to a blank database that I've already created, called newdatabase.
Now, from the command line, I run the following command:
mysqldump -u myusername --password=mypassword olddatabase | mysql -u myusername --password=mypassword -h myhostname newdatabase
That's all there is to it. After doing this, all of the data stored in olddatabase will be found in newdatabase.