mysql赋予用户权限grant all privileges on

linux下在mysql控制台下,如果遇到:access denied for @'localhost' (using password :no)

解决办法 :赋予权限给localhost并给定密码

grant all privileges on *.* to '用户名'@'host' identified by '密码';

flush privileges;

grant 权限1,权限2,...权限n on  数据库名称.表名称 to 用户名@用户地址 identified by '连接口令';

  • 权限1,权限2..权限n代表14种权限,分别为:select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等。
  • all privileges代表赋予用户所有全部权限。
  • 数据名称.表名称,如果用*.*表示,说明赋予用户服务器上所有数据库所有表的权限。
  • 用户地址可以是localhost,可以使ip地址、机器名字、域名。也可以用'%'表示任何地址连接。
  • '连接口令'不能为空,否则会赋予权限失败。

eg:grant all privieges on *.* to root@localhost identified by '123123'

意思是用给来自本机localhost的用户分配权限,用root/123123密码登陆所有数据库中的所有表

原文地址:https://www.cnblogs.com/jsh-tianshi/p/3713223.html