C# 使用 phpMyAdmin 更改 MySql 区分大小写?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/937886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change MySql Case sensitivity with phpMyAdmin?
提问by runxc1 Bret Ferrier
I am running Blogengine.Net and have noticed that the tables are all created lower case (table name be_settings) but a lot of the queries are written mixedcase (Select * from be_Settings). This works fine if your MySql instance is running on Windows or set for capatability with Windows. I am getting an error as my hosting provider MySql instance is case sensitive. Is there a setting I can change to fix this error through phpMyAdmin? I don't want to have to fish through all of the code and fix BlogEngine.Net if I don't have to.
我正在运行 Blogengine.Net 并注意到所有表都是小写创建的(表名 be_settings),但很多查询都是混合大小写的(从 be_Settings 中选择 *)。如果您的 MySql 实例在 Windows 上运行或设置为与 Windows 兼容,则这可以正常工作。我收到一个错误,因为我的托管服务提供商 MySql 实例区分大小写。是否可以更改设置以通过 phpMyAdmin 修复此错误?如果不需要,我不想浏览所有代码并修复 BlogEngine.Net。
采纳答案by runxc1 Bret Ferrier
If you are trying to solve this for BlogEngine.Net you can easily rename all of the tables to use CamelCase as all of the queries in BlogEngine.Net are written using CamelCase.
如果您正在尝试为 BlogEngine.Net 解决这个问题,您可以轻松地将所有表重命名为使用 CamelCase,因为 BlogEngine.Net 中的所有查询都是使用 CamelCase 编写的。
回答by nickf
How is the database being created? You might find that the queries which create the tables are using the correct case:
数据库是如何创建的?您可能会发现创建表的查询使用了正确的案例:
CREATE TABLE be_Settings ( ... )
It's just that myisam tables are stored as files in the filesystem, and since it's on Windows, they're just converted to lower case. If you create the database from these queries on a linux system, you'll find that all the tables are in the correct case.
只是 myisam 表作为文件存储在文件系统中,并且由于它在 Windows 上,因此它们只是转换为小写。如果您在 linux 系统上根据这些查询创建数据库,您会发现所有表都在正确的情况下。
The lesson from this is to always make tables names lower case...
从中得到的教训是始终使表名小写......
回答by Chaos
The setting you are after is lower_case_table_names (set to 1 or 2). Unfortunately, this would need to be set on the MySQL daemon start, not through phpmyadmin. Could you ask your hosting provider to do this for you?
您所追求的设置是lower_case_table_names(设置为1 或2)。不幸的是,这需要在 MySQL 守护进程启动时设置,而不是通过 phpmyadmin。您可以要求您的托管服务提供商为您做这件事吗?
回答by Chris Henry
Case sensitivity in MySQL table names is specific to the OS. MySQL data is stored in files, which are subject to whatever rules the OS enforces. Linux IS case-sensitive, for example.
MySQL 表名中的区分大小写特定于操作系统。MySQL 数据存储在文件中,文件受操作系统强制执行的任何规则的约束。例如,Linux 区分大小写。
There is a variable 'lower_case_table_names' that can be manipulated, but it seems like you'd have to recreate all your tables.
有一个可以操作的变量“lower_case_table_names”,但似乎您必须重新创建所有表。
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html
http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitive.html