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?? 

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 @ !!! )

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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.