查看mysql账户的权限INSERT command denied to user 'dataview'@'118.144.137.111' for table

如果出现以下错误:请查看mysql账户权限:

java.lang.Exception: java.sql.BatchUpdateException: INSERT command denied to user 'dataview'@'118.144.137.111' for table 'ycb_mcs_station'
	at s2jh.biz.station.service.StationService.insertCountryDB(StationService.java:204)
	at s2jh.biz.station.service.StationService$$FastClassBySpringCGLIB$$b74d3980.invoke()
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
	at s2jh.biz.station.service.StationService$$EnhancerBySpringCGLIB$$b79b80e2.insertCountryDB()
	at s2jh.biz.factory.service.impl.BindCardDataBaseServiceImpl.insertCountryDB(BindCardDataBaseServiceImpl.java:146)
	at s2jh.biz.factory.service.impl.BindCardDataBaseServiceImpl.insert(BindCardDataBaseServiceImpl.java:68)
	at s2jh.biz.factory.service.impl.BindCardDataBaseServiceImpl$$FastClassBySpringCGLIB$$478dc668.invoke()
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
	at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:717)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)

 

权限表
mysql数据库中的3个权限表:user 、db、 host
权限表的存取过程是:
1)先从user表中的host、 user、 password这3个字段中判断连接的IP、用户名、密码是否存在表中,存在则通过身份验证;
2)通过权限验证,进行权限分配时,按照useràdbàtables_privàcolumns_priv的顺序进行分配。即先检查全局权限表user,如果user中对应的权限为Y,则此用户对所有数据库的权限都为Y,将不再检查db, tables_priv,columns_priv;如果为N,则到db表中检查此用户对应的具体数据库,并得到db中为Y的权限;如果db中为N,则检查tables_priv中此数据库对应的具体表,取得表中的权限Y,以此类推。
二.MySQL各种权限(共27个)
(以下操作都是以root身份登陆进行grant授权,以p1@localhost身份登陆执行各种命令。)
1. usage
连接(登陆)权限,建立一个用户,就会自动授予其usage权限(默认授予)。
mysql> grant usage on *.* to ‘p1′@’localhost’ identified by ‘123′;
该权限只能用于数据库登陆,不能执行任何操作;且usage权限不能被回收,也即REVOKE用户并不能删除用户。

检查:SELECT * FROM mysql.`user` where `User`='dataview'

结果:

SELECT * FROM mysql.`db` where `User`='dataview'

说明该用户的权限是没有问题的。

然后检查代码,发现使用的数据库是错误的,我用的ycb_japan数据库,但是插入语句的代码还是写的ycb.......

你可能感兴趣的:(mysql)