User and password generation management in mysql _ MySQL

Source: Internet
Author: User
User and password generation management in mysql bitsCN.com

User and password generation management in mysql

Application launch involves user name and password management. as the launch application increases, user name and password management settings become a problem. We also need to grant permissions to users, so we want to write a script for management and see a script written by our colleagues to meet our needs. The idea is to replace letters with numbers, and the account is set based on the database name. The script is as follows:

#!/bin/shpasswd1=$1_sirdbuser=`echo $passwd1|awk '{print tolower($0)}'`dbpassword=`echo $passwd1| awk '{print  tolower($0)}' |sed '//n/!G;s//(./)/(.*/n/)/&/2/1/;//D;s/.//'|awk '{    toupper($0)    gsub(/_/,"",$0)    while($0~/a/)    {        gsub(/a/,"4",$0)    }    while($0~/e/)    {        gsub(/e/,"3",$0)    }           while($0~/i/)    {        gsub(/i/,"1",$0)    }           while($0~/o/)    {        gsub(/o/,"0",$0)    }           while($0~/v/)    {        gsub(/v/,"7",$0)    }    print  tolower($0)}'`echo "grant select,update,delete,insert on $1.* to $dbuser@'%' identified by '$dbpassword';"echo "grant select on $1.* to reader@'%' identified by 'n0p4ssw0rd';"

Usage script followed by db name

[root@dbxxxxx]# ./password.sh userdbgrant select,update,delete,insert on userdb.* to userdb_sir@'%' identified by 'r1sbdr3su';grant select on userdb.* to reader@'%' identified by 'n0p4ssw0rd';

After the preceding SQL statement is generated, a write account and a read account are generated, and commands are executed on the corresponding host.

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.