Reputation: 879
I am developing a web project using Java and MySQL. I am using Mysql Workbench. I started the work but now I need to change the database name. I tried
ALTER DATABASE Test MODIFY NAME = NewTest
and
USE master
GO
ALTER DATABASE Test
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE Test MODIFY NAME = NewTest
GO
ALTER DATABASE NewTest
SET MULTI_USER
GO
But these two are showing syntax error. What is the proper way to change database name in MySQL?
Upvotes: 1
Views: 1157
Reputation: 161
I ran this code from a Microsoft Windows command prompt:
cd %ProgramFiles%\MySQL\MySQL Server 5.6\bin
mysqldump -u username -p -v olddatabase > olddbdump.sql
mysqladmin -u username -p create newdatabase
mysql -u username -p newdatabase < olddbdump.sql
Upvotes: 0
Reputation: 53357
Renaming a schema is not possible in MySQL. For the correct ALTER SCHEMA syntax see the online manual.
Upvotes: 1