Reply
Access denied; you need the CREATE USER privilege for this operation
Old 08-09-2009, 04:09 PM Access denied; you need the CREATE USER privilege for this operation
Average Talker

Posts: 17
Trades: 0
When I try to put "CREATE USER" statement in my php file, I get this ridiculous message: "Access denied; you need the CREATE USER privilege for this operation".

For reference: I'm using Inmotionhosting server, which has the graphic tools MySqlDatabases, MySQLDatabaseWizard, phpMyAdmin, and RemoteMySQL. In "MySQLDatabases", I have selected "Add User to Database" option , added user "db_login", and checked "ALL PRIVILEGES" box to make sure that my administrative user db_login has all the priviliges.

///////////////////////////////////////////////////////////
<?php
addNewUser("user_id","user_pw");

function addNewUser($id,$pw)
{
$db = mysql_connect('localhost','db_login','db_password') or die("Couldn't connect to the database.");
mysql_select_db('my_database') or die("Couldn't select the database");
$query="CREATE USER " . $id . " IDENTIFIED BY PASSWORD " . "'" . $pw . "'";

$result=mysql_query($query) or die ('Query failed: '.mysql_error());
}

?>
//////////////////////////////////////////////////

What could be causing the problem?
DownWithBugs is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 08-10-2009, 02:46 AM Re: Access denied; you need the CREATE USER privilege for this operation
nayes84's Avatar
Super Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 139
Name: John
Location: Tokyo
Trades: 0
probably you need admin privileges or not just privileges for a local database to be able to create user
check mysql website. it may help you
http://dev.mysql.com/doc/refman/5.0/en/create-user.html
__________________
Upload Your Photos For Free | Submit Website To ePhoto Bay
ASP VS JSP
| Free Online Galleries
If I'm("Helpful") Then Add_Talkupation("nayes84") End If

Last edited by nayes84; 08-10-2009 at 02:48 AM..
nayes84 is offline
Reply With Quote
View Public Profile Visit nayes84's homepage!
 
Old 08-12-2009, 09:37 PM Re: Access denied; you need the CREATE USER privilege for this operation
Average Talker

Posts: 17
Trades: 0
I AM the admin becuase it is MY database. I HAVE the admin privileges. I CAN create users with MySQLDatabases tool, and still for some murky reason it does not allow me to create users with PHP/SQL. Anyway, I will get around this issue by having new users insert their user info with login and password into a table, and then I will assign them an access level and let the right users access/modify the other tables. This means I will be doing manually what should have been the database's job. It's OK with me, but I still want to know why it rejects my PHP command
$query="CREATE USER " . $id . " IDENTIFIED BY PASSWORD " . "'" . $pw . "'"; after I login with my id and password, which should in theory give me all administrative privileges.
DownWithBugs is offline
Reply With Quote
View Public Profile
 
Old 08-13-2009, 04:19 AM Re: Access denied; you need the CREATE USER privilege for this operation
nayes84's Avatar
Super Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 139
Name: John
Location: Tokyo
Trades: 0
do you use root password. if so then you should be able to create users. but normal database owners normally wouldn't be given permissions to create users using sql.
__________________
Upload Your Photos For Free | Submit Website To ePhoto Bay
ASP VS JSP
| Free Online Galleries
If I'm("Helpful") Then Add_Talkupation("nayes84") End If
nayes84 is offline
Reply With Quote
View Public Profile Visit nayes84's homepage!
 
Old 08-13-2009, 10:46 AM Re: Access denied; you need the CREATE USER privilege for this operation
chrishirst's Avatar
Super Moderator

Posts: 22,260
Location: Blackpool. UK
Trades: 0
CREATE USER requires SERVER privileges to be granted to the user name that is creating calling the query.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Growing old is mandatory - Growing up is optional
Code Samples | People Counting System | Bits & Bobs
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-15-2009, 03:53 PM Re: Access denied; you need the CREATE USER privilege for this operation
Super Talker

Posts: 101
Trades: 0
Which user name are you trying with? Locally on the MYSQL server or from remote web server? You need to grant the permissions to database user you are using. The same database user at local mysql server and another remote server can be different.

You need to have CREATE USER permission to create the user for the database.
__________________
AccuWebHosting.Com - Windows Hosting Expert
ASP.NET 3.5 | SQL 2005 Database | US Based Hosting Company | 24 X 7 Support | Daily Backups | Uptime Guarantee | Affiliates - $50 Per Sale
| Website Hosting
twhdir is offline
Reply With Quote
View Public Profile
 
Old 08-17-2009, 03:02 AM Re: Access denied; you need the CREATE USER privilege for this operation
Novice Talker

Posts: 8
Name: Kailash
Location: twitter.com/webhosttalk
Trades: 0
I believe "Create user" requires root access to Mysql. From your steps, it seems that you have assign privileges db_login user to particular database (Insert, update, select etc. but not Create user).

Last edited by Kailash1; 08-17-2009 at 03:19 AM..
Kailash1 is offline
Reply With Quote
View Public Profile Visit Kailash1's homepage!
 
Reply     « Reply to Access denied; you need the CREATE USER privilege for this operation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.15121 seconds with 13 queries