Mega Code Archive

 
Categories / Delphi / Examples
 

Mysql how can i rename a database

Question: I want to rename my database from 'TEST' to something more meaningful. Do I have to make a backup, modify the SQL script and then restore it? Answer: While that would work, there is an easier way. Shutdown the mysql server, rename the directory that stores the database from 'TEST' to your desired name. This 'TEST' directory is below the data directory. If you don't know where that is, try: $ mysqladmin variables | grep datadir After renaming, restart the MySQL server and check the grants - they might still contain references to the old database name. You can also use a tool like phpMyAdmin (web interface to mysql) which has an option to rename a database.