Solved

Insert command denied

Posted on 2014-01-17
3
348 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
[X]
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
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 35

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Creating and Managing Databases with phpMyAdmin in cPanel.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

705 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