用于mysql root密码存储的加密算法

时间:2014-04-01 11:04:24

标签: mysql

我想要在mysql中使用哪种加密算法来存储密码的信息。 找到下面的加密密码

| Host      | User | Password                                  | Select_priv | Insert_priv | Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv | Index_priv | Alter_priv | Show_db_priv | Super_priv | Create_tmp_
table_priv | Lock_tables_priv | Execute_priv | Repl_slave_priv | Repl_client_priv | Create_view_priv | Show_view_priv | Create_routine_priv | Alter_routine_priv | Create_user_priv | Event_priv | Trigger_priv | Create_tablespace_priv | ssl_type | ssl_cipher | x509_issuer | x509_subject | max_question
s | max_updates | max_connections | max_user_connections | plugin | authentication_string | password_expired |
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+------------
-----------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+-------------
--+-------------+-----------------+----------------------+--------+-----------------------+------------------+
| localhost | root | ***81F5E21E35407D884A6CD4A731AEBFB6AF209E1B** | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y
           | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |
0 |           0 |               0 |                    0 |        |                       | N                |
| 127.0.0.1 | root | ***81F5E21E35407D884A6CD4A731AEBFB6AF209E1B** | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y
           | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |
0 |           0 |               0 |                    0 |        |                       | N                |
| ::1       | root | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | Y           | Y           | Y           | Y           | Y           | Y         | Y           | Y             | Y            | Y         | Y          | Y               | Y          | Y          | Y            | Y          | Y
           | Y                | Y            | Y               | Y                | Y                | Y              | Y                   | Y                  | Y                | Y          | Y            | Y                      |          |            |             |              |
0 |           0 |               0 |                    0 |        |                       | N                |
+-----------+------+-------------------------------------------+-------------+-------------+-------------+-------------+-------------+-----------+-------------+---------------+--------------+-----------+------------+-----------------+------------+------------+--------------+------------+------------
-----------+------------------+--------------+-----------------+------------------+------------------+----------------+---------------------+--------------------+------------------+------------+--------------+------------------------+----------+------------+-------------+--------------+-------------
--+-------------+-----------------+----------------------+--------+-----------------------+------------------+
3 rows in set (0.00 sec)
for password 

root=*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B

这是什么加密类型

1 个答案:

答案 0 :(得分:1)

Mysql使用SHA1(UNHEX(SHA1("password")))

存储密码

请点击此处示例:

 1. Create user:

    mysql> create user test identified by 'test';
    Query OK, 0 rows affected (0.15 sec)

 2. Check is password



 mysql> select Password from user where user='test';
    +-------------------------------------------+
    | Password                                  |
    +-------------------------------------------+
    | *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29 |
    +-------------------------------------------+
    1 row in set (0.01 sec)

 3. Check the encritp output using our `SHA1(UNHEX(SHA1("")))` formula:

    mysql>  SELECT SHA1(UNHEX(SHA1("test")));
    +------------------------------------------+
    | SHA1(UNHEX(SHA1("test")))                |
    +------------------------------------------+
    | 94bdcebe19083ce2a1f959fd02f964c7af4cfc29 |
    +------------------------------------------+
    1 row in set (0.00 sec)

mysql>