Jump to content

Access Denied?


Devine

Recommended Posts

I was trying to use a mysql query "create database" and it said:

 

Access denied for user 'ppl'@'localhost' to database 'ppl_beta'

 

Any idea why?

(There is a mysql connect usage as well, so i dont know what the problem is..)

Link to comment
Share on other sites

Let me take a shot in the dark, you don't have access to it...

 

Well no kidding, I want to know how I can get access to it.

It is my user (ppl), my database, and I want to create another database on my index.php file.

Link to comment
Share on other sites

phpmyadmin in there check all users and passwords. Some might have higher priviledges than others use the user and password of the higher up. If you don't have access to this, then you shouldn't make a database at that place.  :P

Link to comment
Share on other sites

$link = mysql_connect('localhost', 'ppl', 'PASSWORD');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

$sql = 'CREATE DATABASE ppl_'.$post_userid;
if (mysql_query($sql, $link)) {
    echo "Database ppl_$post_userid created successfully\n";
} else {
    echo 'Error creating database: ' . mysql_error() . "\n";
}

 

This is the code, and I'm connecting via host connect I presume.... What shall I change?

Link to comment
Share on other sites

Do you only get that error message when run a query with CREATE DATABASE. If that's the case then the ppl user doesn't have sufficient privileges for creating databases and tables and thus you are getting that error message.

 

There is nothing you can do within your code to change your privileges or to override this. You will have to login to mysql using root (or any other user that has sufficient privileges to change another user's privileges) to grant CREATE Privileges for the ppl user.

Link to comment
Share on other sites

Do you only get that error message when run a query with CREATE DATABASE. If that's the case then the ppl user doesn't have sufficient privileges for creating databases and tables and thus you are getting that error message.

 

There is nothing you can do within your code to change your privileges or to override this. You will have to login to mysql using root (or any other user that has sufficient privileges to change another user's privileges).

 

user privileges for  a mysql user? or the web host user? (ppl is a web host user) and I tried with a mysql user and it gave the same message (I gave it all of the possible privileges)

Link to comment
Share on other sites

If you are using shared hosting, alot of times you are only allowed a certain number of database, and they usually block the create database command.

 

Chances are, that is the problem, unless you say differently.

Link to comment
Share on other sites

If you are using shared hosting, alot of times you are only allowed a certain number of database, and they usually block the create database command.

 

Chances are, that is the problem, unless you say differently.

 

My limit is about 9999, lol ... so I'm sure having 2 database's doesnt make it exceed that..

 

Login to Cpanel then go to MYSQL then tick the box for all permissions then there shouldn't be a problem...

 

Where in cPanel?

Link to comment
Share on other sites

try if the select statement will run because maybe the privilege  is limited

Let me take a shot in the dark, you don't have access to it...

by the way this is the coolest answer i saw in this forum lol you will kill everybody in that answer

Link to comment
Share on other sites

try if the select statement will run because maybe the privilege  is limited

Let me take a shot in the dark, you don't have access to it...

by the way this is the coolest answer i saw in this forum lol you will kill everybody in that answer

 

I can't really use a "select" statement when the database isn't created yet, now can I?

Link to comment
Share on other sites

first have you tried running the query in your db say if your using the PHPMYADMIN or any if the query still dont run then im pretty sure that it wont allow you to to create but you can only do some select etc.

Link to comment
Share on other sites

i you cant create in phpmyadmin then much more in php script

i guess what the admin is telling you have to use the pword for host user not for regular user now if thats still not working hhmmm i guess tell them to create db for you lol

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.