1

I am trying to rename my database by the following query:

RENAME DATABASE my_db TO newDB;

but its showing me the following error response:

Error Code: 1064. You have an error in your SQL syntax; check the manual that
 corresponds to your MySQL server version for the right syntax to use near 'DATABASE
 activation_server_db TO activationserver' at line 1

Please help me find where I am going wrong?

4
  • @codemania , hi I am new user on stackoverflow, what does this mean when you get votes in minus, as in this post I have -2 votes? Commented Mar 13, 2014 at 9:08
  • stackoverflow.com/questions/67093/… Commented Mar 13, 2014 at 9:11
  • @amir see this for your question about voating stackoverflow.com/help/privileges/vote-down Commented Mar 13, 2014 at 9:12
  • @codemania , oh my GOD stackoverflow is a whole science :P , its really interesting! Commented Mar 13, 2014 at 9:28

4 Answers 4

2

Use these few simple commands

mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql

or For InnoDB, the following seems to work: create the new empty database, then rename each table in turn into the new database:

RENAME TABLE old_db.table TO new_db.table;

You will need to adjust the permissions after that.

Sign up to request clarification or add additional context in comments.

Comments

1

I follow these simple steps:

  1. Create new database
  2. Backup the old database
  3. Restore old database under new database

Comments

1

You can use mysqldump

using mysqldump

mysqldump [OPTIONS] --database oldSchema > oldSchema.sql
mysql new_schema < oldSchema.sql

Comments

0

You need to create a dump of your db and then create a new db with different name with that dump.

If it is online you need to take ofline it for avoiding data loss

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.