Solved

Insert command denied

Posted on 2014-01-17
3
337 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 142

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now