Jump to content

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


Feenix

Recommended Posts

hi, have a problem with this.... Connection to db is ok (with no mysql errors), but server sent error: "SELECT command denied to user ''@'localhost' for table ...". In another application running under another user on that server I haven't this problem. I have also granted privileges for that user on database. Could help sb?? 

Link to comment
Share on other sites

It doesn't look like you've defined a username to connect to mysql. Go back and look at your connection string.

As I wrote, I can connect to the mysql server with no problems, so conn string is correct (otherwise i couldn't connect to it).

 

Check the grant permissions for the username.

username HAS permissions for select, update and delete too, but problem is that serv returns that damned error ( I sent it EXACT - there is no user between those quotation marks before @ !!! )

Link to comment
Share on other sites

are you sure you are not connecting as an anonymous user that has no permissions?

 

create a basic connection file on the server for testing like this, straight out of the php manual, to verify the connection settings:

<?php
// Connecting, selecting database
$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
   or die('Could not connect: ' . mysql_error());
echo 'Connected successfully';
mysql_select_db('my_database') or die('Could not select database');

// Performing SQL query
$query = 'SELECT * FROM my_table';
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

// Printing results in HTML
echo "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
   echo "\t<tr>\n";
   foreach ($line as $col_value) {
       echo "\t\t<td>$col_value</td>\n";
   }
   echo "\t</tr>\n";
}
echo "</table>\n";

// Free resultset
mysql_free_result($result);

// Closing connection
mysql_close($link);
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.