Mysql PASSWORD
From w3cyberlearnings
Contents |
MySQL PASSWORD Function
This function creates a password string from plaintext password. The result of this function is used for encrypting MySQL user password of the user grant table.
Syntax PASSWORD
- str: plaintext password
PASSWORD(str);
Note
PASSWORD() function is a one way encryption. This function is used for the MySQL authentication system. For password encryption in your application (NOT MySQL authentication system), you should use MD5() or SHA2().
Example 1
mysql> SELECT PASSWORD('pass123'); +-------------------------------------------+ | PASSWORD('pass123') | +-------------------------------------------+ | *FB6E1F205D675BC29B052DB14CCEFE7759C5FF7E | +-------------------------------------------+ 1 row in set (0.00 sec)
Example 2
mysql> INSERT INTO userpassword(username,password) -> VALUES('Bob',PASSWORD('toppassword12')); Query OK, 1 row affected (0.00 sec) mysql> SELECT * FROM userpassword; +----+----------+-------------------------------------------+ | id | username | password | +----+----------+-------------------------------------------+ | 1 | Bob | *778BAB8782FCC5A487E2EA701572A50613DC8445 | +----+----------+-------------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT * FROM userpassword -> WHERE password=PASSWORD('toppassword12'); +----+----------+-------------------------------------------+ | id | username | password | +----+----------+-------------------------------------------+ | 1 | Bob | *778BAB8782FCC5A487E2EA701572A50613DC8445 | +----+----------+-------------------------------------------+ 1 row in set (0.00 sec)