mysql query is not case sensitive issue

Transfer from http://blog.csdn.net/qishuo_java/article/details/40118937

Transfer from https://www.cnblogs.com/wuyun-blog/p/8527492.html

Identify the user name for the user id 'AAMkADExM2M5NjQ2LWUzYzctNDFkMC1h' data: select * from usertable where id = 'AAMkADExM2M5NjQ2LWUzYzctNDFkMC1h'; record two results occur. This is strange, id has been set as the primary key, how will repeat it? Is mysql vulnerabilities. Later found two id value out of the original query are different, see no difference between a fraud, a closer look you will find two different id just have a case of letters, the two are id:

'AAMkADExM2M5NjQ2LWUzYzctNdFkMC1h',

'AAMkADExM2M5NjQ2LWUzYzctNDFkMC1h'.

       When the original mysql query, there is a case insensitive. It can be solved through binary keyword.

       There are two solutions:

      The first: let mysql query is case sensitive

       select * from usertable where binary id = 'AAMkADExM2M5NjQ2LWUzYzctNDFkMC1h';

       The second: be identified at the time of construction of the table

        create table table_name {

                   id varchar(32) binary;

        }

In mysql, there is a case where there are problems:

(1) Keywords: case does not select * fRom table_name and select * from table_name effect is the same

(2) identifier (e.g., a database and table names): case-insensitive. If there is table users, and then select * from users select * from uSers the same effect. This is related to the Internet, said the operating system, the operating system on all Unit (except for HFS + using the Mac OS) are case sensitive, and in the windows is not case sensitive. (Online not verified this statement, I'm on the windows server2003 is not case-sensitive)

Alias ​​(3) Table: case does not select m * from users m where M.username = 'aa';.

(4) column alias: case does not select uName from (select username as uname from users where id = 768) t

Guess you like

Origin www.cnblogs.com/dlp-527/p/11478984.html