#####################数据库装包改密####################### #####################先准备mysql数据包及自动化安装包####################### #!/bin/bash systemctl restart firewalld systemctl enable firewalld firewall-cmd --set-default-zone=trusted sed -i 's/=enforcing/=permissive/' /etc/selinux/config setenforce 0 tar -xf mysql.tar.gz cd 09.mysql 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 systemctl restart mysqld systemctl enable mysqld yum -y install expect.x86_64 ###############取初始密码#################################### first_password=`awk '/root@localhost:/{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 root@localhost 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数据库装包改密码脚本
原创
©著作权归作者所有:来自51CTO博客作者大宝dayday见的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章