How to modify mysql Procedure through command shell

Create a random alphanumeric string with mysql query

Why we need this?

We used to generate random strings for generating passwords or generating keys which are used for accessing sensitive information through a URL. When you want to generate a unique random key for a table, it is always better to generate the key in mysql rather than the server side scripting language. Generating random key in mysql procedure, avoid multiple key generation and checks the existence of generating a key, which reduces multiple mysql connection calls.

MySQL Custom Function to generate alphanumeric random string

Use the below code to create a custom function which generates a random key:

Note: The maximum length of random string that can be generated by the above function is 100. You can increase the limit by changing the function return type.

Using custom function in a procedure:

Implement the created custom function generate_random  :