重置:mysql-5.7 root用户密码为:root
2017-08-02 23:05
543 查看
# reset-root.sh # 功能:初始化mysql-5.7初始密码的脚本 root/root # 时间:2017/08/02 10:46:07 #!/bin/bash #mycnf="./my.cnf" mycnf=" /etc/my.cnf" # IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT sed -i '/symbolic-links=0/a\skip-grant-tables=1' $mycnf service mysqld restart if [ `rpm -qa | grep expect | wc -l` -eq 0 ] then yum clean all yum install -y expect fi /usr/bin/expect <<-EOF spawn mysql -uroot expect "*mysql>" send "use mysql;\r" #send "SET PASSWORD = PASSWORD('root');\r"; send "update user set authentication_string = password('root'), \ password_expired = 'N', password_last_changed = now() where user = 'root';\r"; send "flush privileges;\r" send "delete from user where user<>'root';\r" send "update user set host='%' where user='root';\r" send "flush privileges;\r" send "grant all PRIVILEGES on *.* to 'slave'@'%' identified by 'slave';\r" send "flush privileges;\r" # 退出MySQL expect "*mysql>" send "exit;\r"; expect eof EOF # IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT sed -i -e '/skip-grant-tables=1/d' $mycnf service mysqld restart
相关文章推荐
- ubuntu 16.04系统下解决MySQL 5.7版本的root用户重置密码问题
- [PHP] ubuntu 16.04系统下解决MySQL 5.7版本的root用户重置密码问题
- ubuntu 16.04系统下解决MySQL 5.7版本的root用户重置密码问题
- Mysql重置root用户密码(windows)
- Mysql(Linux)root用户密码重置方法
- [MySQL] CentOS7 mysql5.7 忘记root密码 重置root密码 1045
- centos 7 下mysql 安装后重置root用户密码
- Mysql 5.7 忘记root密码或重置密码的详细方法
- MySQL 5.7 重置root默认密码
- MySQL(root用户)密码重置
- UBUNTU MYSQL 5.7+ 重置root密码
- MySQL重置root用户密码的方法
- XAMPP笔记之重置MySQL/MariaDB Root用户密码
- [转]MySQL(root用户)密码忘记重置
- MySQL5.7 版本重置 root 密码
- MySQL(root用户)密码重置
- Mysql 5.7 忘记root密码或重置密码的详细方法
- MySQL 5.7以上 root用户默认密码问题【转】
- 关于Windows系统MySQL5.6数据库root用户密码重置的注意事项