<p>Craft has a lot of <strong>foreign keys</strong> between tables, so something might be getting tripped up there. Here's what I'd suggest...</p>

<p>Instead of using phpMyAdmin to "Rename database to", perhaps try this:</p>

<ol>
<li>Export your existing DB to an SQL file.</li>
<li>Create a new DB with the name you want.</li>
<li>Import your SQL into the new DB.</li>
</ol>

<p>Assuming that all goes smoothly, you can then go back and drop your original database.</p>

CC BY-SA 3.0
2014-07-08T17:59:26.593Z
2014-07-08T17:59:26.593Z
Lindsey D
<p>MySQL doesn't have a native command for "Rename database" (well, they <a href="https://dev.mysql.com/doc/refman/5.1/en/rename-database.html" rel="nofollow noreferrer">did at one point</a>, but removed it shortly thereafter), so any MySQL client that offers that functionality ends up writing their own implementation for it.</p>

<p>That is usually somethings as simple as:</p>

<ol>
<li>Export data and schema to a backup.</li>
<li>Create new database with new name.</li>
<li>Import data and schema from backup.</li>
<li>Delete old database.</li>
</ol>

<p>But it looks like phpMyAdmin is trying to be more clever than that and failing.  I would try <a href="https://craftcms.stackexchange.com/a/834/57">Lindsey's suggestion</a> as a workaround.</p>

<p><em>Update</em></p>

<p>Looking at the error, it looks like you've got a dash (-) in your database table name prefix.  That's considered a "special" character by MySQL and must be escaped in backticks `table-prefix.table-name`, which phpMyAdmin doesn't appear to be doing, so it's likely there is a phpMyAdmin bug there, too.</p>

CC BY-SA 3.0
2014-07-09T08:29:33.140Z
Brad - thanks for your explanations and suggestion
John de Beer
CC BY-SA 3.0
2014-07-08T18:53:33.707Z
2014-07-08T19:29:58.447Z
2017-04-13T12:51:00.160Z
Brad Bell
<p>I get this error when trying to change a database name on a new dev with no entries:
<img src="https://i.sstatic.net/E9Oik.png" alt="phpmyadmin change db name error"></p>

<p>What can be done?</p>

<database>
Error when trying to change the database name
# Error when trying to change the database name

(Asked by: username_0 on 2014-07-08)

I get this error when trying to change a database name on a new dev with no entries:
![phpmyadmin change db name error](https://i.sstatic.net/E9Oik.png)

What can be done?

**Tags:** database

---

## 2 answers

### Answer by username_1 on 2014-07-08. Score: 2 | Accepted answer

Craft has a lot of **foreign keys** between tables, so something might be getting tripped up there. Here's what I'd suggest...

Instead of using phpMyAdmin to "Rename database to", perhaps try this:

1. Export your existing DB to an SQL file.
2. Create a new DB with the name you want.
3. Import your SQL into the new DB.

Assuming that all goes smoothly, you can then go back and drop your original database.


---

### Answer by username_2 on 2014-07-08. Score: 3

MySQL doesn't have a native command for "Rename database" (well, they [did at one point](https://dev.mysql.com/doc/refman/5.1/en/rename-database.html), but removed it shortly thereafter), so any MySQL client that offers that functionality ends up writing their own implementation for it.

That is usually somethings as simple as:

1. Export data and schema to a backup.
2. Create new database with new name.
3. Import data and schema from backup.
4. Delete old database.

But it looks like phpMyAdmin is trying to be more clever than that and failing. I would try [Lindsey's suggestion](https://craftcms.stackexchange.com/a/834/57) as a workaround.

*Update*

Looking at the error, it looks like you've got a dash (-) in your database table name prefix. That's considered a "special" character by MySQL and must be escaped in backticks `table-prefix.table-name`, which phpMyAdmin doesn't appear to be doing, so it's likely there is a phpMyAdmin bug there, too.

> **Comments:**
> **username_0**: Brad - thanks for your explanations and suggestion  

---

