How to force case sensitive table names?

梦想与她 提交于 2019-11-26 10:42:23

问题


I\'m working on a MySQL database in windows.

I must move it into a Linux environment. MySQL database contains a lot of tables and stored procedures which are CASE SENSITIVE.

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.

I don\'t have access to the MySQL configuration in the linux environment so I cant change MySQL settings to case insensitive mode.

Is there any way to force MySQL (v5.x) to use case sensitive table names in windows?


回答1:


Read all this: http://dev.mysql.com/doc/refman/5.0/en/identifier-case-sensitivity.html

Then add this system variable to the server section, [mysqld], of my.ini and restart mysql:

/my.ini: lower_case_table_names=2




回答2:


Have a look at this article - http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.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.




回答3:


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 Box or VMware player with TurnKey - MySQL Appliance.

In my personal experience, I've found quite useful to have a VM with a configuration similar to the deployment environment to diagnose problems.




回答4:


On windows put lower_case_table_names=2 at the end of file C:\ProgramData\MySQL\MySQL Server 5.7\my.ini




回答5:


i add this line and it solve the different case problem

lower_case_table_names=1

in /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




回答6:


Add this property to lower_case_table_names=2 to my.ini



来源:https://stackoverflow.com/questions/6248735/how-to-force-case-sensitive-table-names

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!