Is it possible to use ALTER DATABASE to rename a mysql database?

I use PDO with PHP to create a new database and then a new user with privileges in this database. If one of them fails, I want to rename the database and the user so that they can be deleted later, and the names will be available.

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

+7
database php mysql pdo alter
source share
2 answers

Duplicate - see How to quickly rename a mysql database (change schema name)

In short, no. MySQL does not have a quick / easy way to rename databases. You must use mysqladmin and mysqldump from the command line. See Question above for all details.

+8
source share

It is not possible to use ALTER to rename a MySQL database, but you can do this with phpMyAdmin. After selecting the database from the left pane, go to the "Operations" section, and then rename the database. Another way: go to the data folder in MySQL and rename the folder name of your database.

+3
source share

All Articles