Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

insert command denied in mysql

Tags:

php

mysql

I have a database table from which, when I select data with username and password, it works but when I insert some data in that table with same username and password it shows me the error

INSERT command denied to user 'username'@'localhost' for table 'tablename' 

I searched using Google and someone else had the same problem with db size. I checked my db and when I go directly to phpmyadmin to insert data into the table, it works, but when I call a query to the table from a PHP script, it gives me the error.

like image 907
souce code Avatar asked Apr 18 '11 05:04

souce code


1 Answers

I had a similar problem after moving my site from one hosting account to another. The problem was caused by a SQL query (INSERT) that referenced the old database. replacing the old db with the new db name (or just removing the db name altogether) solved the problem. But this mistake stumped the support people at my hosting company.

Example:

INSERT INTO old_db_name.table_name ( ) VALUES (); 

Changed to:

INSERT INTO new_db_name.table_name ( ) VALUES ( ); 

Hope this helps and makes sense.

like image 173
Rafik Bari Avatar answered Sep 23 '22 13:09

Rafik Bari