1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
$ mysql -u root -p mysql> use mysql; mysql> select Host,User from mysql.user; # 创建用户并设置密码 mysql> create user 'wordpress' identified by 'password'; #更改用户访问是外网访问还是只能本地访问 mysql> update mysql.user set Host='localhost' where User='wordpress'; # 更新密码,5.7的数据库使用'authentication_string'字段替代了'Password'字段 mysql> update user set authentication_string=password('pass') where User='wordpress' and Host='localhost'; # 如果没这一行可能也会报一个错误,因此需要运行这一行 mysql> update user set plugin="mysql_native_password"; mysql> select Host,User from mysql.user; # 授予用户访问Wordpress数据库的权限 mysql> grant all privileges on wordpress.* to 'wordpress'@'localhost' identified by 'pass'; # 刷新权限 mysql> flush privileges; |