PDA

View Full Version : One DB user per DB?



newguy
05-14-2009, 01:28 AM
I have been accustom to using one database user for multiple databases. When I try to do this with bluehost I get such an error...


Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'bhaccount_dbname'@'localhost' (using password: YES) in /home/bhaccount/public_html/index2.php on line 24

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/bhaccount/public_html/index2.php on line 25
The fix was to create multiple database users and to give one user to database. If my website requires multiple connections to a single database by multiple scripts, each script needs to have its own user name.

I suppose their is a reason for this. Could one please enlighten me?

Hopefully this helps someone else if they run into this same issue.

Thank You!

*I just wish I knew about this sooner. It took a good while to debug this issue.*

LTDInvest
05-14-2009, 12:37 PM
One user for multiple databases is no problem. Just click on the mySQL database icon. Scroll down to Add User To Database and add the user. Currently have at least 5 of my 21 databases using the same user.

newguy
05-14-2009, 06:41 PM
I have done that.

The page in question with the issue is a page that pulls from 3 different databases.

At first I got the error above. The second I added more db users the problem was fixed, just as long as it was one user per database.

felgall
05-14-2009, 07:12 PM
Is there any particular reason why you have one application using multiple databases rather than having everything in one database?