How to grant privileges to a mysql user by using php.
I work on a php project where I can
1: Create database by using php script.
2: Create user in mysql by using php script.
3: Grant access to user for the specific database by using php script.
Problem is in step no 3.
I need to know how can grant access to user for a specific database by using php script, where the user has full access control on has database but the other database should not accessible.
Need some privileges techniques overcome the above problem.
If any one have knowledge about the privileges then please help me!
Thank
Best regard
How to grant privileges to a mysql user by using php?
Moderator: General Moderators
Re: How to grant privileges to a mysql user by using php?
It's just an SQL query like any other. Use mysql_query("GRANT blah blah blah").. Obviously the user you connect to MySQL with will need to have the GRANT privilege.
Re: How to grant privileges to a mysql user by using php?
In fact, using the GRANT query will create the user specified if it's not existing. So Step 2 can be omitted.
There are 10 types of people in this world, those who understand binary and those who don't
Re: How to grant privileges to a mysql user by using php?
I'd still do it anyway otherwise the user will be created without a password..VladSun wrote:In fact, using the GRANT query will create the user specified if it's not existing. So Step 2 can be omitted.
Re: How to grant privileges to a mysql user by using php?
I don't think so. At least it will not happen with a proper GRANT query:
[sql] GRANT ALLON mydatabase.*TO myuser@myhostIDENTIFIED BY 'mypassword' [/sql]
[sql] GRANT ALLON mydatabase.*TO myuser@myhostIDENTIFIED BY 'mypassword' [/sql]
There are 10 types of people in this world, those who understand binary and those who don't
Re: How to grant privileges to a mysql user by using php?
Hi VladSun & onion2k!
Thanks for helping!
My script is working now.
Best Regard.
Thanks for helping!
My script is working now.
Best Regard.