SELECT command denied to user 'user'@'localhost' for table 'table'

mysql, mysql-workbench

Solution

grant all privileges on bedgeaj_medmax.transactions to 'bedgeaj_root'@'%'  identified by 'password';

Try this one.

EDIT

Error: select command denied to user '<userid>'@'<ip-address>' for table '<table-name>'

See comment by pisces in the above link.

Problem

I have deployed my database on MySQL Database server. I have a user 'bedgeaj_root@localhost' and it has all the permissions. But it still giving me the error : SELECT command denied to user 'bedgeaj_root'@'localhost' for table 'transactions' While searching on the net, I studied that it is some user permission issue. But I don't understand that why it is giving this error as I have given all the permission to this user. Here is the screen shot of my cPanel user permissions screen: Here goes my stack trace: ``` Caused by: net.sf.jasperreports.engine.JRException: Error executing SQL statement for : itemizedStatementReport_patientBalance at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:246) at net.sf.jasperreports.engine.fill.JRFillDataset.createQueryDatasource(JRFillDataset.java:1073) at net.sf.jasperreports.engine.fill.JRFillDataset.initDatasource(JRFillDataset.java:667) at net.sf.jasperreports.engine.fill.JRBaseFiller.setParameters(JRBaseFiller.java:1235) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:859) at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:804) at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:652) at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59) at net.sf.jasperreports.engine.fill.JRThreadSubreportRunner.run(JRThreadSubreportRunner.java:205) ... 1 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SELECT command denied to user 'bedgeaj_root'@'localhost' for table 'transactions' at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) at com.mysql.jdbc.Util.getInstance(Util.java:382) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3603) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3535) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1989) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2150) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2119) at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:2281) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.createDatasource(JRJdbcQueryExecuter.java:239) ... 9 more ``` I am using this query: ``` SELECT alias.patient_id , SUM(alias.balance) AS balance from ( SELECT v.patient_id,trx.trx_id,trx.trx_status,trx.trx_seq,pb.billing_id,v.visit_id,v.visit_dt,forma t(SUM(tl.net_amount) - ifnull((SELECT SUM(pl.applied_amount+pl.discount_amount) FROM payment_lines pl where pl.trx_line_id = tl.trx_line_id),0.0),2)AS balance FROM ((transactions trx JOIN trx_lines tl ON (trx.trx_id = tl.trx_id))JOIN patient_billing pb ON(pb.billing_id = trx.billing_id))JOIN visits v ON (pb.visit_id = v.visit_id) where trx.trx_seq='4' AND trx.trx_status='PENDING' AND (date_format(v.visit_dt,'%Y/%m/%d')<date_format(DATE_SUB(NOW(), INTERVAL 1 day),'%Y/%m/%d')) group by tl.trx_id) alias where alias.patient_id = $P{patient_id} ``` group by alias.patient_id] What I am doing wrong?

Original source

Related problems