用命令行工具,登录
1、以下命令就可以授权
@'%':远程访问授权 @'localhost'本机访问
mysql> grant all privileges on *.* to '用户名'@'%' identified by '密码'
with grant option;
mysql> flush privileges;
mysql> select host, user ,authentication_string from user;
+-----------+---------------+-------------------------------------------+
| host | user | authentication_string |
+-----------+---------------+-------------------------------------------+
| localhost | root | *F639C88D14D6F97EE915C916066C13C7E6127BEA |
mysql5.7以上password改成了authentication_string。
grant all privileges on `db`.* to 'user'@'%' identified by 'password';
flush privileges;
grant all privileges on `db`.* to 'user'@'localhost' identified by 'password';
flush privileges;
授权某个数据库访问权限
参考: