copy and rename a mysql database through ssh

SarcasticDwarf

Diamond Member
Jun 8, 2001
9,574
2
76
So today's trivia question is as follows:

using SSH, how do I copy an existing database in full, then rename the copied database (and overwrite)

for example, I have
user_dat1 (live)
user_dat2 (development-3 weeks old)

What I want is to have
user_dat1 (live)
user_dat2 (development-same as live at time of copy)


guesses?
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
ssh is irrelevent
create the db user_dat2
then
mysqldump -eq user_dat1 | mysql user_dat2

Or you could go down to the data directory and copy the files directly