Jump to content

db connection


RON_ron

Recommended Posts

Nope.

 

I'm asking if it is safe to use the username and password (given by the host) in the php connection?

or can the usernames and passwords which was created when creating the database should be safer and used to connect to the database?

 

E.g.1

<?php
$link = mysql_connect("localhost","username_given_by_host","password_given_by_host");
mysql_select_db("db_1");

 

E.g.2

<?php
$link = mysql_connect("localhost","username_created_when_creating_the_db","password_created_when_creating_the_db");
mysql_select_db("db_1");

Link to comment
https://forums.phpfreaks.com/topic/218865-db-connection/#findComment-1136221
Share on other sites

Are you asking if you should use your administrator account or connect to the database with a different user in your application?

 

I always create a separate user for each application database - I have dozens of applications on my site, each running on their own database, and each has their own user.  I do that so that if one of the users somehow gets compromised they only have access to the single database.  Could be overkill but it makes me feel better.  I would never put an administrator's password into any PHP connection code, though.

Link to comment
https://forums.phpfreaks.com/topic/218865-db-connection/#findComment-1136364
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.