best way to store password in mysql?

Discussion in 'MySQL' started by jnm, Jul 17, 2007.

  1. #1
    please let me know the best way to insert passwords into a mysql database...

    1. varchar (20) using PASSWORD('$password')
    2. varchar (20) using MD5('$password')
    3. other?


    This one is important! If I were to encrypt/hash the passwords in the mysql DB and then would have to upgrade servers moving the DB to another server, would the new mysql be able to decrypt the passwords?


    thanks!
     
    jnm, Jul 17, 2007 IP
  2. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #2
    password, and md5 are one-way encryption, you can't decrypt them.

    varchar (20) md5 is the best way.
     
    gibex, Jul 17, 2007 IP
  3. Clark Kent

    Clark Kent Guest

    Messages:
    122
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    varchar 20 is not enough.
    you have to use varchar 32.
    md5 generates 32 character.

    example: 1aabac6d068eef6a7bad3fdf50a05cc8
     
    Clark Kent, Jul 18, 2007 IP
  4. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #4
    thx clark, I forgot :)
     
    gibex, Jul 18, 2007 IP