Im using mysql for a db server. I am wonering what the query would be to create a database and assign it a username and password using sql if possible.
Thanks,
Printable View
Im using mysql for a db server. I am wonering what the query would be to create a database and assign it a username and password using sql if possible.
Thanks,
Have a look at this, it may help you :)
Cheers,
RyanJ
Thats not really what i was looking for, but thanks anyways. I know how to create a db, but when i do it has no username or password set for it. What i want to do is be able to set a username and password for the database when i create it.
Ah, Sorry I miss-understood your question.
I don't think this is possible in PHP, if it were then you could create / edit databases through PHP at will and this could pose some security risks.
Cheers,
RyanJ
Yeah, i guess i was kinda thinking more along the lines of doing it in SQL. Im sure there has got to be a way of doing it.Quote:
Originally Posted by sciguyryan
You can create a database in PHP and set permissions on it, as long as you have loggied in as the root mysql user or as a user with priviledges to grant permissions on a database.
Make sure that you have used mysql_select_db('MySql') before executing this query using the mysql_query() function.
Code:GRANT ALL ON dbname.* TO 'username'@'hostname' IDENTIFIED BY 'password';
Thats interesting to know, thanks for the correction visualAd :)
Cheers,
RyanJ