2013-08-06 88 views
7

我在MySQL數據庫服務器上部署了我的數據庫。我有一個用戶'bedgeaj_root @ localhost',它擁有所有權限。但它仍然給我的錯誤:對錶'table'的用戶'user''localhost'拒絕SELECT命令

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

雖然在網上搜索,我的研究,這是有些用戶權限問題。但我不明白,爲什麼它給這個錯誤,因爲我已經給這個用戶的所有權限。

這裏是我的cPanel用戶權限屏幕的截屏:

bedgeaj_root@localhost permissions screen

這裏去我的堆棧跟蹤:

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 

我使用此查詢:

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]

我做錯了什麼?

+4

「,因爲我已向該用戶授予所有權限。」 - 不會出現那種方式。 –

+0

我已經爲用戶指定了bedgea_root @ localhost的所有權限,包括SELECT權限。除一個特定的查詢外,其他所有查詢均可正常運行 –

+0

CURRENT_USER的SHOW GRANTS;你得到了什麼? – Mihai

回答

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

試試這個。

編輯

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

看到在上面的鏈接雙魚座評論。

+0

我已經嘗試過了,但問題依然存在。 –

+0

我現在也提供了堆棧跟蹤。 –

+0

我現在重複檢查了我在查詢中使用的表,不管它們是否存在於數據庫中。它們確實存在於數據庫中。 –

1

我有類似的問題。我的本地數據庫是通過來自另一臺服務器的轉儲創建的,並且本地服務器對開發服務器上的用戶沒有所有權限。我得到這個錯誤試圖使用續集親備份我的本地數據庫。然後我嘗試mysqldump並得到了一個不同的錯誤:出現錯誤:1449:使用LOCK TABLES時,用戶指定爲定義者('joey'@'127.0.0.1')不存在。所以我全力以赴。到[email protected]並修復它。

1

我有一個類似的問題。
在我的情況下,出現錯誤是因爲MySQL區分大小寫Linux

this

In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory (and possibly more, depending on the storage engine). Triggers also correspond to files. Consequently, the case sensitivity of the underlying operating system plays a part in the case sensitivity of database, table, and trigger names. This means such names are not case sensitive in Windows, but are case sensitive in most varieties of Unix.

如果GRANT命令之前運行,改變tablenameTABLENAME/Tablename就可以解決問題。

相關問題