MySQL在添加一个新用户后
grant all privileges on db.* to 'user'@'%' identified by 'password'
从本机用命令行登录,使用密码登录不了。
不使用密码可以登录,但没有任何权限。
解决办法:
再添加一个用户
grant all privileges on db.* to 'user'@'localhost' identified by 'password'
参考:http://www.cnblogs.com/yyshenren/archive/2008/07/23/1249157.html
原因据说是:如果没有本地帐户(user@localhost),使用user帐户登录时,mysql_install_db将优先考虑创建一个本地的匿名帐户。那么结果将是root账户会被当作一个匿名帐户来处理。原因则在于,匿名帐户拥有一个比user@%账户更加具体的host字段值,从而在user表排序的时候会相对出现的更早。
grant all privileges on db.* to 'user'@'%' identified by 'password'
从本机用命令行登录,使用密码登录不了。
不使用密码可以登录,但没有任何权限。
解决办法:
再添加一个用户
grant all privileges on db.* to 'user'@'localhost' identified by 'password'
参考:http://www.cnblogs.com/yyshenren/archive/2008/07/23/1249157.html
原因据说是:如果没有本地帐户(user@localhost),使用user帐户登录时,mysql_install_db将优先考虑创建一个本地的匿名帐户。那么结果将是root账户会被当作一个匿名帐户来处理。原因则在于,匿名帐户拥有一个比user@%账户更加具体的host字段值,从而在user表排序的时候会相对出现的更早。