Create a mysql database and set permissions using php

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
eruiz1973
Forum Newbie
Posts: 2
Joined: Mon Jun 30, 2003 12:28 pm

Create a mysql database and set permissions using php

Post by eruiz1973 »

I need to have a php file that creates a mysql database and also sets permissions as follows:

GRANT ALL PRIVILEGES ON `demo` . * TO "coldfusion"@"localhost" WITH GRANT OPTION ;

GRANT ALL PRIVILEGES ON `forum` . * TO "any"@"www" WITH GRANT OPTION ;

as well as


GRANT ALL PRIVILEGES ON `forum` . * TO "any"@"localhost" WITH GRANT OPTION ;

Thanks
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

execute as any other query??? just that the user you do this with must have superuser access.. (to create database)

mysql_query ('CREATE DATABASE mybeer');
mysql_query ('GRANT ALL ON mybeer TO ...');
eruiz1973
Forum Newbie
Posts: 2
Joined: Mon Jun 30, 2003 12:28 pm

Post by eruiz1973 »

Thanks. I've never used php so it's a little complex for me to understand the query. What you wrote is all I need in the php code page?

Thanks
Em
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved this to Databases as it did not belong in PHP - Advanced.

Mac
Post Reply