How to turn on case sensitivity for mysql in WAMP
Posted by: YeeP79 (66.170.252.---)
Date: June 08, 2016 03:45PM

Hello, I have WAMP installed and running with multiple sites on it right now, but am having an issue with case sensitivity. The current site that I am working is hosted on a linux box, and has a database name with some capital letters, some lower case. I believe the culprit is here:

lower_case_file_system ON
lower_case_table_names 1

The website that I am trying to work on was written in PHP and has many, many references to the database name. Rather than pick through tons of files renaming the database name to all lower case, I should be able to make this variable change and give the database the correct name. However, whenever I edit the my.ini file and insert the "lower_case_table_names=0" under the [mysqld] "heading", the mysql server will not restart.

Any tips on this would be much appreciated.

Options: ReplyQuote
Re: How to turn on case sensitivity for mysql in WAMP
Posted by: Otomatic (Moderator)
Date: June 08, 2016 04:03PM

Hi,

Impossible. Windows is case insensitive.
You can turn lower_case directives in all directions, it is absolutely impossible to make Windows case sensitive.
The names of the database and those tables are represented as folder and, whatever you do, Windows folder named FoO is the same as the folder named fOo.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: How to turn on case sensitivity for mysql in WAMP
Posted by: YeeP79 (---.dish.com)
Date: June 08, 2016 04:07PM

Thanks for the response Otomatic. I was afraid that would be the case. Well, I guess I need to figure out how to change the port reference in the code and I can use my vagrant box to host the database. Or, pick apart a bunch of files and rename the database..... decisions, decisions!

Options: ReplyQuote
Re: How to turn on case sensitivity for mysql in WAMP
Posted by: SimonT (---.lightspeed.stlsmo.sbcglobal.net)
Date: June 14, 2016 07:42AM

It would be better for you to create a Named Constant for the database name in a myconfig.php file you create on your site. You would "require_once" that file in all of your PHP files so that the constants defined in the myconfig.php file will be available to all code.


An example is:

Create a file named myconfig.php (or any other name you want, but one that instantly says "Hey, I'm a configuration file"winking smiley and put in the directory with the rest of your PHP files.

Code the following in the file:

define("DBNAME", "name of the database in whatever case is needed for it to work properly"winking smiley;

When you want the name of the database, you code DBNAME instead of "the name of the database"

Changing it in the myconfig.php file will "change" it everywhere in your application.

As to manually changing things - there are editors which replace strings in a global find and replace action across multiple files. You could use something like that to change the database name to the name of the defined constant.

Always think in terms of "how can I make this easier to change in the future?"

As to upper or lower case or mixed case on names - it is always better to just stick to lowercase unless absolutely forced - as by some programming language requirement)

Most instances you will run into will be case insensitive and a very few will be case sensitive.

If you stick to lower case you will head off any problems with names in the future.

It is never wise to have two things named the same but with different case. It is far too easy to make a typing error and specify the wrong one.

All programming languages used on the web allow very long variable names. Use that, but don't over do it, and make the names of your variables, and such, meaningful.

Options: ReplyQuote


Sorry, only registered users may post in this forum.