Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Insert command denied

Posted on 2014-01-17
3
343 Views
Last Modified: 2014-01-22
Hello

I am getting this error from a webpage when trying to insert into a table in the 'databasename'

INSERT command denied to user 'theuser'@'localhost' for table 'thetable'

However when i do a show grants on the database i get this


GRANT USAGE ON *.* TO 'theuser'@'%' IDENTIFIED BY PASSWORD 'xxxx'
GRANT ALL PRIVILEGES ON `databasename`.* TO 'theuser'@'%'

I'm not sure what the first line means but surely the second line means the user has all privileges on that database and should be able to insert?

thanks
0
Comment
Question by:andieje
3 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 39788685
if those permissions where given in some session, but no "FLUSH PRIVILEGES" was issued, and/or the user did not reconnect yet, it might be "missing" still in the session.

or you are just simply looking at the wrong mysql instance,. ...
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 250 total points
ID: 39788892
Create a user "theuser" with the host "localhost".

For some reason, the rights for theuser@% don't apply when connecting from localhost

https://dev.mysql.com/doc/refman/5.5/en/adding-users.html

HTH,
Dan
0
 
LVL 33

Accepted Solution

by:
snoyes_jw earned 250 total points
ID: 39794279
The rights for user@% DO apply when connecting from localhost. The problem is that MySQL ships with an anonymous user, ''@localhost, which has access only to the `test` database. The privilege system matches the most exact host name first - ''@localhost matches all localhost users better than user@%.

So, you can create user@localhost, but then you have two separate users to maintain, and this problem will appear again when you want different_user@%.

The best thing to do is to DROP USER ''@localhost;

This is in the manual at http://dev.mysql.com/doc/refman/5.6/en/access-denied.html - find the text starting, "If you cannot figure out why"
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP: concatenate query 13 79
PHP & MySQL - Rounding Results from a Select Query 3 34
mysql between clause 2 32
Present Absent from working date rage 11 35
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question