mysql java.sql.SQLSyntaxErrorException: Access denied for user 'renren'@'%' to database 'renren-fast
mysql java.sql.SQLSyntaxErrorException: Access denied for user ‘renren’@’%’ to database 'renren-fast’
这个是用户权限的问题,没有远程访问权限时出现这个问题,刚刚安装的myql的root密码账号只有localhost的操作权限.
- 授权:
GRANT ALL on renren-fast.* to ‘renren’@’%’ identified by ‘123456’ with grant option;注意:renren-fast为数据库名,renren为用户名,123456为用户密码.如果要给所有库授权GRANT ALL on . to ‘renren’@’%’ identified by ‘123456’ with grant option; - 刷新权限:
FLUSH PRIVILEGES;
报错场景:新创建的数据,没有授权,导致Java程序报错。