MySQL database security solution (5) _ MySQL

Source: Internet
Author: User
MySQL database security solution (5) The following is the PASSWORD function


Select password ('pa55word ');
+ ---------------------- +
| PASSWORD ('pa55word') |
+ ---------------------- +
| 1d35c6556b8cab45 |
+ ---------------------- +
1 row in set (0.00 sec)


The following is the ENCRYPT function.


Select encrypt ('pa55word ');
+ --------------------- +
| ENCRYPT ('pa55word') |
+ --------------------- +
| Up2Ecb0Hdj25A |
+ --------------------- +
1 row in set (0.17 sec)


Each of the above functions returns an encrypted string. To distinguish the case sensitivity of an encrypted string, it is best to define this field as a char binary type when using ENCRYPT to generate an encrypted string.

Three encryption methods are listed above, but I think using MD5 encryption is the best. This is because the plaintext password can be displayed in the processing list or query logs for easy tracking. The following INSERT statement inserts a record, and the password uses MD5 for encryption:

Insert into table1 (user, pw) VALUE ('user1', MD5 ('password1 '))

You can use the following statement to verify the password:

SELECT * FROM table1 WHERE user = 'user1' AND pw = MD5 ('password1 ')

The hash encryption method can be used to encrypt the password. with this method, the password cannot be restored to plain text.

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.