Which permissions for MySQL Database

Soldato
Joined
1 Feb 2006
Posts
8,188
Hey guys,
Over the past while I have been playing around with MySQL databases just on my machine but I now want to try and work with some live versions on my hosting. I am using the mysql admin tool within my hosting control panel to set up users and so on. I have set up a user with 'grant all privleges'. Is this secure enough to use within PHP scripts on my website or for a public database user should I be reducing these privileges somewhat? I have googled on this but can't find the info I am looking for. Basically what I need to know is when I set up my PHP file containing the database connection details do I use a user there with full privileges or can I use a special user just for that purpose? Thanks in advance
 
For the best possible security logically you would only assign the privileges absolutely required by that particular script. So yes, create a new user just for your script and give it only the access it needs.

That way, should anything happen [someone hacks your script/SQL injection etc] the damage is prevented/limited.
 
Even better you should write stored procs and only give the script access to execute them. Then no malicious sql can be run.
 
Thanks for the info guys. I think I will have a file with database connection details and it requires a database username and password. What permissions would be required though? I will disable options like 'drop database' etc to make it more secure. So really I should have a full access account to admin the db myself, but for my website my db user should only have fewer privileges? Am i correct on this? Thanks
 
Back
Top Bottom