Monday, February 2, 2009

Rename database and table for mySQL

1. Find out the database location on the system. It is at /var/lib/mysql on my CentOS 5.2. Change to that directory:
cd /var/lib/mysql

2. Stop mySQL server:
/etc/init.d/mysql stop

3. Rename the name of the database.
mv mydb.old

4. Rename the table files in the new database directory:
mv oldtable.frm newtable.frm
mv oldtable.MYD newtable.MYD
mv oldtable.MYI newtable.MYI

5. Start mySQL server:
/etc/init.d/mysql start

No comments: