如何改变MySQL中数据库名称的大小写?[英] How can I change case of database name in MySQL?

本文是小编为大家收集整理的关于如何改变MySQL中数据库名称的大小写?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

我尝试使用

RENAME DATABASE SPM TO spm;

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

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

推荐答案

没有数据库命令可以执行此操作.基本上,您必须在数据库之外进行.以下是一些参考,概述了可能的解决方案.在此问题 >

这可能是您的情况下的样子

mysqladmin create spm
mysqldump SPM | mysql spm

验证了所有内容是否为了订购一切,您可以删除原始数据库.

drop database SPM

参考 rename datame database 1 // Rename数据库2

[注:" rename datame database "命令:此语句已在MySQL 5.1.7中添加,但发现很危险,并在MySQL 5.1.23中被删除.]

其他推荐答案

RENAME {DATABASE | SCHEMA} db_name TO new_db_name;

在MySQL 5.1.7中添加了此陈述,但发现很危险,并在MySQL 5.1.23中被删除.它旨在启用升级5.1数据库,以将5.1中实现的编码数据用于映射数据库名称到数据库目录名称.但是,使用此陈述可能会导致数据库内容的丢失,这就是将其删除的原因.请勿在存在的早期版本中使用RENAME DATABASE.

要执行使用新编码升级数据库名称的任务,请改用ALTER DATABASE db_name UPGRADE DATA DIRECTORY NAME.

其他推荐答案

使用mysql_dump倾倒旧模式的数据库内容(它产生SQL输出,可以包含所有对象创建语句),切换到新模式,并执行该脚本mysql> . dump.sql

如果它是一个大数据库,则可能需要一段时间,但这是最安全的方法(确保在进行转换过程时使用数据库暂停任何应用程序).

>

当您满意一切正常时,删除旧模式.

本文地址:https://www.itbaoku.cn/post/597640.html

问题描述

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

I tried using

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

My server version: 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

References Rename database 1 / Rename database 2

[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.]

其他推荐答案

RENAME {DATABASE | SCHEMA} db_name TO new_db_name;

This statement was added in MySQL 5.1.7 but was found to be dangerous and was removed in MySQL 5.1.23. It was intended to enable upgrading pre-5.1 databases to use the encoding implemented in 5.1 for mapping database names to database directory names . However, use of this statement could result in loss of database contents, which is why it was removed. Do not use RENAME DATABASE in earlier versions in which it is present.

To perform the task of upgrading database names with the new encoding, use ALTER DATABASE db_name UPGRADE DATA DIRECTORY NAME instead.

其他推荐答案

Use mysql_dump to dump out the database contents of the old schema (it produces SQL output, and can include all the object CREATE statements), switch to the new schema, and execute that script mysql> . dump.sql

If it's a large database, this may take a while, but it's the safest way to do it (make sure you suspend any applications using the database while the conversion process is going on).

Delete the old schema when you're satisfied that everything worked.