如何在MySQL中更改数据库名称的大小写?

问题描述:

我的数据库名称是 SPM ,我想将其更改为 spm (小写字母)。

My Database name is SPM and I want to change it to spm (small letters).

我尝试使用

RENAME DATABASE SPM TO spm;

,但我收到以下错误消息:

, but I am getting the following error message:

ERROR 1064 (42000): 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 SPM to spm' at line 1

我的服务器版本:5.0.45

做它。你基本上必须在数据库之外。以下是一些可能的解决方案的参考。在此问题中已回答相当不错。

There is no database command to do it. You basically have to do it outside the database. Below are some references outlining possible solutions. It has been answered pretty good in this question

这可能是你的情况下应该是这样的

This is probably what it should look like in your case

mysqladmin create spm
mysqldump SPM | mysql spm

在验证一切正常后,您可以删除原始数据库。

After you have verified that everything is in order you can drop the original database.

drop database SPM

参考资料
重命名数据库1 / 重命名数据库2

[有关 RENAME DATABASE 命令:此语句在MySQL 5.1.7中添加,但被发现是危险的,并在MySQL 5.1.23中删除。]

[Note on "RENAME DATABASE" command: This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23.]