dbpw=`grep 'temporary password' /var/log/mysqld.log|cut -d ' ' -f 13` newdbpw="123456Aa" mysql --connect-expired-password -uroot -p$dbpw << EOF set global validate_password.policy=0; set global validate_password.length=1; ALTER USER 'root'@'localhost' IDENTIFIED BY ${newdbpw}; create user 'root'@'%' identified by ${newdbpw}; grant all privileges on *.* to root@'%' with grant option; flush privileges; quit EOF
my.cnf 默认配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd