Error: select command denied to user ''@'' for table ''
前端 未结 14 1470
被撕碎了的回忆
被撕碎了的回忆 2020-11-27 16:30

In my website, I am using MySQL database. I am using a webservice where in I do all my database related manipulations.

Now In one of the methods of that webservice,

相关标签:
14条回答
  • 2020-11-27 16:55

    I had the exact same error message doing a database export via Sequel Pro on a mac. I was the root user so i knew it wasn't permissions. Then i tried it with mysqldump and got a different error message: Got error: 1449: The user specified as a definer ('joey'@'127.0.0.1') does not exist when using LOCK TABLES

    Ahh, I had restored this database from a backup on the dev site and I hadn't created that user on this machine. "grant all on . to 'joey'@'127.0.0.1' identified by 'joeypass'; " did the trick.

    hth

    0 讨论(0)
  • 2020-11-27 16:57

    select command denied to user ''@'' for table ''

    This problem is a basically generated after join condition are wrong database name in your join query. So please check the your select query in join table name after database.

    Then solve it for example its correct ans ware

    string g = " SELECT `emptable`.`image` , `applyleave`.`id` , `applyleave`.`empid` , `applyleave`.`empname` , `applyleave`.`dateapply` , `applyleave`.`leavename` , `applyleave`.`fromdate` , `applyleave`.`todate` , `applyleave`.`resion` , `applyleave`.`contact` , `applyleave`.`leavestatus` , `applyleave`.`username` , `applyleave`.`noday` FROM `DataEMP_ems`.`applyleave` INNER JOIN `DataEMP_ems`.`emptable` ON ( `applyleave`.`empid` = `emptable`.`empid` ) WHERE ( `applyleave`.`leavestatus` = 'panding' ) ";
    

    The join table is imputable and applyleave on the same database but online database name is diffrent then given error on this problem.

    0 讨论(0)
  • 2020-11-27 16:57

    You need to grant SELECT permissions to the MySQL user who is connecting to MySQL. See:

    http://dev.mysql.com/doc/refman/5.0/en/privilege-system.html

    http://dev.mysql.com/doc/refman/5.0/en/user-account-management.html

    0 讨论(0)
  • 2020-11-27 16:57

    If you are working from a windows forms application this worked for me

    "server=localhost; user id=dbuser; password=password; database=dbname; Use Procedure Bodies=false;"
    

    Just add the "Use Procedure Bodies=false" at the end of your connection string.

    0 讨论(0)
  • 2020-11-27 17:02

    The problem is most probably between a . and a _. Say in my query I put

    SELECT ..... FROM LOCATION.PT

    instead of

    SELECT ..... FROM LOCATION_PT

    So I think MySQL would think LOCATION as a database name and was giving access privilege error.

    0 讨论(0)
  • 2020-11-27 17:02

    Similar to other answers I had miss typed the query.

    I had -

    SELECT t.id FROM t.table LEFT JOIN table2 AS t2 ON t.id = t2.table_id
    

    Should have been

    SELECT t.id FROM table AS t LEFT JOIN table2 AS t2 ON t.id = t2.table_id
    

    Mysql was trying to find a database called t which the user didn't have permission for.

    0 讨论(0)
提交回复
热议问题