错误:对用户'< userid>'@@'< ip-address>'的选择命令被拒绝表'< table-name>' [英] Error: select command denied to user '<userid>'@'<ip-address>' for table '<table-name>'
问题描述
在我的网站上,我正在使用MySQL数据库.我正在使用Web服务,在其中进行所有与数据库相关的操作.
In my website, I am using MySQL database. I am using a webservice where in I do all my database related manipulations.
现在,在该Web服务的一种方法中,出现以下错误.
Now In one of the methods of that webservice, I get the following Error.
拒绝用户"@"访问表"
select command denied to user ''@'' for table ''
有什么问题吗?
下面是我得到该错误的代码.我尝试调试,发现它在一行失败
Below is the code where I get that error. I tried debugging and found that it fails at the line
MySqlDataReader result1 = command1.ExecuteReader();
这是我的代码:
String addSQL = "Select Max(`TradeID`) from `jsontest`.`tbl_Positions";
MySqlConnection objMyCon = new MySqlConnection(strProvider);
objMyCon.Open();
MySqlCommand command = objMyCon.CreateCommand();
command.CommandText = addSQL;
MySqlDataReader result = command.ExecuteReader();
//int j = command.ExecuteNonQuery();
while (result.Read())
{
MaxTradeID = Convert.ToInt32(result[0]);
}
objMyCon.Close();
for (i = 1; i <= MaxTradeID; i++)
{
String newSQL = "Select `Strike`,`LongShort`,`Current`,`TPLevel`,`SLLevel` from `json`.`tbl_Position` where `TradeID` = '" + i + "'";
MySqlConnection objMyCon1 = new MySqlConnection(strProvider);
objMyCon1.Open();
MySqlCommand command1 = objMyCon1.CreateCommand();
command1.CommandText = newSQL;
MySqlDataReader result1 = command1.ExecuteReader();
objMyCon2.Close();
推荐答案
数据库用户无权执行选择查询.
database user does not have the permission to do select query.
如果您具有对mysql的root访问权限,则可以向用户授予权限
you can grant the permission to the user if you have root access to mysql
http://dev.mysql.com/doc/refman/5.1/en/grant.html
您的第二个查询位于不同表的不同数据库上.
Your second query is on different database on different table.
String newSQL = "Select `Strike`,`LongShort`,`Current`,`TPLevel`,`SLLevel` from `json`.`tbl_Position` where `TradeID` = '" + i + "'";
与您连接的用户无权访问该数据库或特定表中的数据.
And the user you are connecting with does not have permission to access data from this database or this particular table.
您考虑过这件事吗?
这篇关于错误:对用户'< userid>'@@'< ip-address>'的选择命令被拒绝表'< table-name>'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!