Creating Database permison

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Creating Database permison

Post by reecec »

Hi,

I wonder if someone could help

i have a php script to make a database, but the error is that the user im connected as does not have persmison to access this database im trying to create but you have to asign users to a database in cpanel. so how can you create a database if the user is denied.


thanks reece
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You create the database in CPanel most often.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you can create user with ALL PRIVELEDGES in cpanel as well.
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

thanks, but the user does have full priveleges but only when you asign users to a database. so how can you create a database when loged in as a user that isnt yet set up for this database.

also yes i can do it in cpanel but i need it to be in the script
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

reecec wrote:thanks, but the user does have full priveleges but only when you asign users to a database. so how can you create a database when loged in as a user that isnt yet set up for this database.

also yes i can do it in cpanel but i need it to be in the script
So you want to do an action that a user does not have priviledges to? impossible.
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

thanks yes so it seems i thought the same


how can a user create a database in php if you have to asign the users in cpanel to the database after its created.

how does cpanel let you create a database and then select users to it. in php you have to create database when loged in as a user
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

CPanel has a user that has more privileges than the users you are assigning access to for that database.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

This sounds like a hosted account that likes to charge for extra databases. They typically take away your right to create databases because it takes revenue away from them.

If you have the right to make more databases in your account, or if you have root level privilege to your database server (doubtful on shared accounts) I would say just change your user's permission in phpMyAdmin or even at the CLI. but that would require you having sufficient privileges (under your logged in account) to GRANT permissions.
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

Everah wrote:This sounds like a hosted account that likes to charge for extra databases. They typically take away your right to create databases because it takes revenue away from them.

If you have the right to make more databases in your account, or if you have root level privilege to your database server (doubtful on shared accounts) I would say just change your user's permission in phpMyAdmin or even at the CLI. but that would require you having sufficient privileges (under your logged in account) to GRANT permissions.

the last part from what everah said is true so would i be right in saying this:

When your on cpanel and you create a database that is on there server so basicly root access but when im loged in as a user using php i havent got priveleges per user to create a database. i would need a server with root access.

but im sure many scripts need to create databases
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

No, many scripts do not need to create a database. Use an existing one, sure, but few, if any, need to create a database just for themselves.
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

Hi, hope you all had a good xmas

i found out you cant make databases in php when your hosting has cpanel so i have used cUrl to create it in cpanel through php

thanks reece
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

reecec wrote:Hi, hope you all had a good xmas

i found out you cant make databases in php when your hosting has cpanel so i have used cUrl to create it in cpanel through php

thanks reece
cPanel should have nothing to do with your ability to make a database. That permission should be at the database level. I think.

How were you able to do it with cURL?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Is there a reason behind needing to create these databases? I mean a real one; experimentation is legit.

I just think if you're building an application that needs new databases all the time (and dynamically created) that there's something wrong with the design on a grossly fundamental level.
reecec
Forum Contributor
Posts: 218
Joined: Sun Apr 02, 2006 7:12 am

Post by reecec »

everah, I have made it so it logs into cpanel and in the address it contains the db name

Code: Select all

$resultdata = exec("$curl_path 'http://$cpanel_user:$cpanel_password@$cpanel_host:2082/frontend/$cpanel_skin/sql/adddb.html?db=$db_name_data'");

it was from this website http://www.zubrag.com/scripts/cpanel-da ... reator.php

___

feyd, sorry but i dont think you can comment like that if you dont know the application im trying to create, the database is a one of creation in sign up they see and know noting about this.

thanks reece
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you feel I can't comment, then please enlighten me/us on why your application needs to create databases.
Post Reply