Home » Php » php – Can I use ALTER DATABASE to rename a mysql database?

php – Can I use ALTER DATABASE to rename a mysql database?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I am using PDO with PHP to create a new database and then a new user with privileges on that database. In case one of them fails, I want to rename the database and user so that they can be deleted later and the names are available.

Is it possible to rename a mysql database using the ALTER DATABASE?

How to&Answers:

Duplicate — see How do I quickly rename a mysql database (change schema name)

In short, no. MySQL doesn’t have a quick/simple way to rename databases. You have to use mysqladmin and mysqldump from the command line. See question above for all the details.

Answer:

To rename MySQL database is not possible using ALTER but you can do it using phpMyAdmin.
After Selecting your database from left panel go to “Operations” then rename the database.
Another way.. go to your data folder on MySQL and rename the folder name of your database.