A case-sensitive mysql solution _ MySQL

Source: Internet
Author: User
A mysql case-sensitive solution today, a colleague told me that the account and password were not case-sensitive when we logged on to the game. later, we found that creating accounts and roles were not case-sensitive. After thinking about the login process, Mysql is case insensitive.

I checked the information online. Mysql supports case-sensitive solutions. Several solutions have been found.

First, modify the database settings to make Mysql support case sensitivity. this solution is too radical and there is too much data in the database. in this way, the change may not cause any problems.

Second, modifying the table structure and character set is similar to the first solution, but the risk is lower.

Third, modify the stored procedure or SQL statement. The advantage is that the database structure is not moved. The disadvantage is that all changes are involved.

After the trade-off, we chose the third solution, which only modifies the two stored procedures for login and creation.

The method is to use the binary keyword of mysql.

BINARY is not a function, but a type conversion operator. it is used to force a string after it to be a BINARY string. it can be understood as case sensitive during string comparison.

The test is as follows:

Mysql> select binary 'ABC' = 'abc' ret1, 'ABC' = 'abc' ret2; + -------- + | ret1 | ret2 | + -------- + | 0 | 1 | + -------- + 1 row in set (0.00 sec)

The above is a case-sensitive mysql solution _ MySQL content. For more information, see PHP Chinese network (www.php1.cn )!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.