MySQL Username and Pass w/PHP

They have: 2 posts

Joined: May 2004

Hey, I wanted to know how I can create a new user for MySQL through PHP using variables from a form.

I am creating a script that installs another script that I'm planning to write. The user inserts a database name, database password, and username, and I want the script to create all three of those things. (In short, its using the variables to define what the username and password for the database they create will be.

If anyone can help, that would be great.
(If it helps, teh variables for the three are:
1) $databasename (for the database name)
2) $username (for the username)
3) $password (for the password))

Thanks,
Frank

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

You will have to run SQL statements from a user with the apropriate permissions (root, mostlikely). There isn't anything special you have to do in PHP. Just run the SQL statements (with mysql_query, etc.).

Mark Hensler
If there is no answer on Google, then there is no question.

They have: 2 posts

Joined: May 2004

And those statements would be? Sticking out tongue

(Hehe, I'm a no0b, I need spoon feeding here.)

s0da's picture

He has: 157 posts

Joined: Mar 2004

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.