创建用户并授权
GRANT ALL PRIVILEGES ON *.* TO 'caoxiaobo'@'%' IDENTIFIED BY 'Caoxiaobo0917!' WITH GRANT OPTION;
给root授予所有权,包括远程访问
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1' WITH GRANT OPTION;
第一次安装,查看root密码
grep 'temporary password' /var/log/mysqld.log
去掉密码策略,修改my.cfg,在[mysqld]添加
validate_password = off
修改密码
修改密码[注意:后面的分号一定要跟上]
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者:
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
使修改生效
FLUSH PRIVILEGES;