views:

16

answers:

1

What is the best way to handle mysql database users connection in PHP?

I have a web server running a PHP application on MySQL. I have created a database user for the application: dbuser1 with limited access - only for query, insert and update tables. No alter table.

Now the question is, should i use the same dbuser1 widely in my scripts, so if there are 100 current people using my system and hence 100 scripts running parallel they all connect to the database with the same dbuser1? or should i create a few users and assign each script a different user or load-balance between the dbusers ?

A: 

Just use the same user. As long as that user has appropriate access rights (and it sounds like you've got that covered), you'll be ok.

You might want to check that your MySQL installation is configured to allow enough concurrent connections to support your expected usage load, but the defaults should be fine for most sites.

rikh