Mysql 添加用户并授所有权

创建用户并授权
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;

 

上一篇:如何避免数据库被黑


下一篇:myslq8.0.6远程连接授权问题