Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rename database name - mysql [closed]

how i can rename my database? There is any way in phpmyadmin? or what is the sql code?

I have already tried using RENAME DATABASE

thanks

like image 335
user455318 Avatar asked Oct 11 '22 03:10

user455318


2 Answers

If you're using MyISAM only, the quickest way is

/etc/init.d/mysql stop
cd /var/lib/mysql
mv <old db name> <new db name>
/etc/init.d/mysql start

It's not pretty, but it does work. You'll need root access.

This way might work if you're using InnoDB tables, but I have no experience there, so I won't vouch for it.

like image 77
Jon Bright Avatar answered Oct 14 '22 04:10

Jon Bright


Here is an answer from SO: How do I quickly rename a MySQL database (change schema name)?

This seems to be your best bet. The RENAME DATABASE command, if it is even available to you, may wipe your data. Don't pursue that angle.

like image 43
IAmTimCorey Avatar answered Oct 14 '22 05:10

IAmTimCorey