RON_ron Posted November 16, 2010 Share Posted November 16, 2010 When I need to post / get data out of the MySQL, if I use the username and password which is the same username and password to access the CP, 1. is this a bad thing to do? 2. Is it safe/risky? <?php $conn = mysql_connect("localhost","the_un1","the_pw1"); $db = mysql_select_db("the_db"); Link to comment https://forums.phpfreaks.com/topic/218865-db-connection/ Share on other sites More sharing options...
fenway Posted November 17, 2010 Share Posted November 17, 2010 Huh? Link to comment https://forums.phpfreaks.com/topic/218865-db-connection/#findComment-1135808 Share on other sites More sharing options...
RON_ron Posted November 17, 2010 Author Share Posted November 17, 2010 I don't really know... but there is an option of creating users + passwords when a creating a database using PhpMyAdmin. So I'm confused. As you see I'm a novice! Link to comment https://forums.phpfreaks.com/topic/218865-db-connection/#findComment-1135813 Share on other sites More sharing options...
fenway Posted November 18, 2010 Share Posted November 18, 2010 So you're asking how to create users? Link to comment https://forums.phpfreaks.com/topic/218865-db-connection/#findComment-1136210 Share on other sites More sharing options...
RON_ron Posted November 18, 2010 Author Share Posted November 18, 2010 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 More sharing options...
jdavidbakr Posted November 18, 2010 Share Posted November 18, 2010 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 More sharing options...
RON_ron Posted November 18, 2010 Author Share Posted November 18, 2010 Hi jdavidbakr. That was exactly what I wanted to know. Many thanks! Ron. Link to comment https://forums.phpfreaks.com/topic/218865-db-connection/#findComment-1136370 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.