Check whether the mysql password has entered the correct script code.

Source: Internet
Author: User

MysqlUser = 'root'

MysqlPassword =''

Function CheckMysqlPassword ()

{

If [-z $ MysqlPassword]

Then

CmdResult = 'mysql-u $ MysqlUser-e quit 2> & 1'

Else

CmdResult = 'mysql-u $ MysqlUser-p $ MysqlPassword-e quit 2> & 1'

Fi

CmdResultLineCount = 'echo $ cmdResult | wc-C'

If (cmdResultLineCount> 1 ))

Then

Printf "Error occurred! \ N "# $ cmdResult! \ N"

Else

Printf "Connect mysql successfully! \ N"

Fi

# Printf "cmdResult = $ cmdResult \ n"

#! For more details:

#! ERROR 1045 (28000): Access denied for user 'root' @ 'localhost'

AccessDenied = 'echo $ cmdResult | grep Access. denied | wc-C'

# If (AccessDenied> 1 ))

# Then

# Printf "Connect failed, access denied. \ n"

# Fi;

#! Can't connect to local MySQL server through socket...

# CannotConnect = 'echo $ cmdResult | grep Can. t. connect | wc-C'

# If (CannotConnect> 1 ))

# Then

# Printf "Connect faild, mysql may not started. \ n"

# Fi

}

Printf "Please input the password for mysql root user :"

Read MysqlPassword

CheckMysqlPassword

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.