Please support us by disabling ad blocker for smarttutorials.net ...

Generate random password in MySQL

Posted by & filed under MYSQL, PHP.

It’s very simple to generate random password in MySQL.

How to generate new random password in MySQL

How to generate new random password in MySQL

Here is sample MySQL query to generate random password.

SELECT substring(MD5(RAND()) from 1 for 10) AS password

To generate random password I’m going use three MySQL functions

1. RAND()

2. MD5()

3. SUBSTRING()

where RAND() function generates random numbers between 0 to 1.

SELECT RAND() AS num

Result :  0.20635062754745653

then MD5() function encrypts generated random number (0.20635062754745653) into encrypted formatted data. like below

SELECT MD5(RAND()) AS num

(ex. SELECT MD5(0.20635062754745653) AS num )

Result : 1e24663af0a4102936cec71d99219a4f

Finally SUBSTRING() function extracts specified length of characters from MD5() function generated string (1e24663af0a4102936cec71d99219a4f)

SELECT substring( MD5(RAND()) from 1 for 10 ) AS num

(ex SELECT substring(’1e24663af0a4102936cec71d99219a4f’ from 1 for 10 ) AS num )

Result : 1e24663af0

 .

Download Premium Only Scripts & 80+ Demo scripts Instantly at just 1.95 USD per month + 10% discount to all Exclusive Scripts

If you want any of my script need to be customized according to your business requirement,

Please feel free to contact me [at] muni[at]smarttutorials.net

Note: But it will be charged based on your customization requirement

Get Updates, Scripts & Other Useful Resources to your Email

Join 10,000+ Happy Subscribers on feedburner. Click to Subscribe (We don't send spam)
Every Email Subsciber could have access to download 100+ demo scripts & all future scripts.

Get Instant Script Download Access!