MySQL database package Change Password script

Source: Internet
Author: User

#################### #数据库装包改密码 #######################

#!/bin/bash
Firewall-cmd--set-default-zone=trusted
Setenforce 0
#tar-XF Mysql-5.7.17-1.el7.x86_64.rpm-bundle.tar
RM-RF mysql-community-server-minimal-5.7.17-1.el7.x86_64.rpm
Yum-y Install perl-data-dumper.x86_64 Perl-json.noarch perl-json-pp.noarch
RPM-UVH mysql-community-*.rpm--nodeps
Systemctl Restart Mysqld
Systemctl Enable Mysqld
Yum-y Install expect.x86_64
############## #取初始密码 ####################################
First_password=\ 'awk ‘/[email protected]:/{print $11}‘ /var/log/mysqld.log\‘
Expect << EOF
Spawn Mysql-uroot-p$first_password
Expect "mysql>" {send "set global validate_password_policy=0;\n"}
Expect "mysql>" {send "set global validate_password_length=6;\n"}
Expect "mysql>" {send "alter user [email protected] identified by \" 123456\ "; \ n"}
Expect "mysql>" {send "quit\n"}
Eof
Sed-i '/^[mysqld]/avalidate_password_policy=0 '/etc/my.cnf
Sed-i '/^[mysqld]/avalidate_password_length=6 '/etc/my.cnf
Systemctl Restart Mysqld

MySQL database package Change Password script

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.