Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Insert command denied

Posted on 2014-01-17
3
Medium Priority
?
366 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 1000 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 1000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

636 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