Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 272010
 

How to rename database in MySQL

Answer:

If you are using MyISAM storage engine, the easiest way is to take down the MySQL server and rename the database folder name.

Else, you can use the mysqldump tool, steps as following:

1. Export the database using mysqldump tool

# mysqldump -u root -p old_db > old_db.sql

2. Create a new database

# mysql -u root -p -e 'create database new_db'

3. Finally import into the new database

# cat old_db.sql |mysql -u root -p new_db

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>