Solved

Access denied; you need the RELOAD privilege for this operation

Posted on 2011-03-21
5
1,674 Views
Last Modified: 2012-05-11
I'm new to PHP and MySQL..

I get the following error when I do the "Flush Privileges" statement:  Access denied; you need the RELOAD privilege for this operation

It actually does to the insert statement above - I don't know if I need the "Flush Privileges" or not, but it was part of the example, and it seems like clearing out the settings on the server was a good idea (if i understand what flushing does correctly)

I created a database using MySQL WorkBench - but i forgot to put an Auto_Increment on the primary key, so I had to add it later.  After adding it, the error started coming up.  I created a whole new table, just to see if it was related to the table, but it's doing it on the new table.

Thanks for your help!!!

<?php
include 'data/config.php';
include 'data/opendb.php';

$query = "INSERT INTO myTable (Name) VALUES ('Name')";
mysql_query($query) or die('Error, insert query failed - 1' . mysql_error());

//This is the error section...

$query = "FLUSH PRIVILEGES";
mysql_query($query) or die('Error, query failed - 2' . mysql_error());

include 'data/closedb.php';
echo "New MySQL user added";


?>

Open in new window

0
Comment
Question by:slightlyoff
  • 3
  • 2
5 Comments
 
LVL 7

Expert Comment

by:Swafnil
ID: 35182230
I haven't found a clear statement that auto_increments cause an implicit flush table but have you checked if the user you are currently inserting data with has the RELOAD privilege?

Please post the result of the following command to see what's exactly causing the above error:
SHOW GRANTS;

Open in new window

0
 
LVL 1

Author Comment

by:slightlyoff
ID: 35191307
Thanks for your quick reply, I won't be back to the project until tomorrow - I'll keep you posted on what I get.

Thanks again!!!
0
 
LVL 1

Author Comment

by:slightlyoff
ID: 35195356
Here's what I got:

'GRANT USAGE ON *.* TO ''myuser''@''%'' IDENTIFIED BY PASSWORD ''xxxxxxxxxxxxx''''
GRANT ALL PRIVILEGES ON `mytable`.* TO ''myuser''@''%'' WITH GRANT OPTION'

I ran the command inside of MySQL WorkBench...

Thanks for your help!
0
 
LVL 7

Accepted Solution

by:
Swafnil earned 500 total points
ID: 35196077
Did you also do a "FLUSH PRIVILEGES" after you granted rights to myuser?

There's also an error in the second GRANT, the database name is probably something else than "mytable", the ON command expects the syntax [DBNAME].[TABLENAME], in your case it would be:

GRANT ALL PRIVILEGES ON [DBNAME].mytable TO ''myuser''@''%'' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Open in new window


See if that fixes the error.

Hope that helps!
0
 
LVL 1

Author Closing Comment

by:slightlyoff
ID: 35217711
Thanks for your help.  Turns out I don't have the permissions to do that.  So, it's all good.  Thanks for your help!
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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

896 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

13 Experts available now in Live!

Get 1:1 Help Now