MySQL 如何强制区分大小写的表名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6248735/
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
How to force case sensitive table names?
提问by Ehsan Khodarahmi
I'm working on a MySQL database in windows.
我正在 Windows 中处理 MySQL 数据库。
I must move it into a Linux environment. MySQL database contains a lot of tables and stored procedures which are CASE SENSITIVE.
我必须将它移到 Linux 环境中。MySQL 数据库包含许多区分大小写的表和存储过程。
When I backup my database, all table names are forced lowercase so when I restore it in Linux it complains because you can't make duplicate tables and stored procedures.
当我备份我的数据库时,所有表名都强制小写,所以当我在 Linux 中恢复它时,它会抱怨,因为你不能制作重复的表和存储过程。
I don't have access to the MySQL configuration in the linux environment so I cant change MySQL settings to case insensitive mode.
我无法访问 linux 环境中的 MySQL 配置,因此我无法将 MySQL 设置更改为不区分大小写的模式。
Is there any way to force MySQL (v5.x) to use case sensitive table names in windows?
有没有办法强制 MySQL (v5.x) 在 Windows 中使用区分大小写的表名?
回答by ATorras
Read all this: 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
Then add this system variable to the server section, [mysqld]
, of my.ini
and restart mysql:
然后将此系统变量添加到服务器部分,[mysqld]
,my.ini
并重新启动 mysql:
/my.ini: lower_case_table_names=2
/my.ini:lower_case_table_names=2
回答by Devart
Have a look at this article - http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html
看看这篇文章 - http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitive.html
Mode 2 allows to store tables with specified lettercase, but anyway, name comparisons won't be case sensitive and you won't be able to store table1
and Table1
at the same time.
模式 2 允许使用指定的字母存储表,但无论如何,名称比较不会区分大小写,您将无法同时存储table1
和Table1
。
回答by Augusto
Unfortunately there's no way of making MySQL on windows to behave 100% as in Linux. What you can do, is to run a minimal VM on Virtual Boxor VMware playerwith TurnKey - MySQL Appliance.
不幸的是,没有办法让 Windows 上的 MySQL 像在 Linux 中一样 100% 运行。您可以做的是在Virtual Box或VMware 播放器上使用TurnKey - MySQL Appliance运行最小的 VM 。
In my personal experience, I've found quite useful to have a VM with a configuration similar to the deployment environment to diagnose problems.
根据我的个人经验,我发现拥有一个配置类似于部署环境的 VM 来诊断问题非常有用。
回答by Evgeny Chashnik
On windows put lower_case_table_names=2 at the end of file C:\ProgramData\MySQL\MySQL Server 5.7\my.ini
在 Windows 上将 lower_case_table_names=2 放在文件 C:\ProgramData\MySQL\MySQL Server 5.7\my.ini 的末尾
回答by Hatem Badawi
i add this line and it solve the different case problem
我添加了这一行,它解决了不同的案例问题
lower_case_table_names=1
lower_case_table_names=1
in /etc/my.cnf
在 /etc/my.cnf
you can see how to set mysql variable "lower_case_table_names" form this page : https://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lower_case_table_names
您可以在此页面中看到如何设置 mysql 变量“lower_case_table_names”:https: //dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_lower_case_table_names
回答by Kris
Add this property to lower_case_table_names=2to my.ini
将此属性添加到lower_case_table_names=2到my.ini