Access denied for user with GRANT priviliege

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Access denied for user with GRANT priviliege



I have a DB named abc_products, with various tables.
One of them is named table1.


abc_products


table1



I created a new DB user named abc_user, and want to restrict its DB access only to that table.


abc_user



I logged to SSH Terminal as root user, and typed:


root


root@host [~]# mysql

Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 5721225
Server version: 5.6.39 MySQL Community Server (GPL)

mysql> use abc_products
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed


mysql> GRANT SELECT ON `table1` TO 'abc_user'@'localhost';
Query OK, 0 rows affected (0.00 sec)



But when I try to connect to MySQL with this user, I get an access denied error in my Chrome Console XHR response:



Connect failed: Access denied for user 'abc_user'@'localhost' (using
password: YES)



I'm using the following PHP code, which works fine If I am to use the real server user that has privileges for the entire DB:


$mysqli = new mysqli("localhost","abc_user","password","abc_products");


if (mysqli_connect_errno()) {
printf("Connect failed: %sn", mysqli_connect_error());
exit();
}
/* database section end */

$content= array();
$Name = $mysqli->real_escape_string($_REQUEST['seller']);
$mysqli->set_charset('utf8mb4');

$fbResult = $mysqli->query("select `Text`,DATE_FORMAT(`UpdatedAt`, '%m/%d/%Y %H:%i') as `UpdatedAt`,`ItemId` from table1 where `Name` = '$Name' ORDER BY UpdatedAt DESC");
if($fbResult){
while($fb = mysqli_fetch_assoc($fbResult)){
$feedbacks = $fb;
}
}

header('content-type:application/json');
print json_encode($content);



What is wrong?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Better method to check all objects' parameters with a single call