Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.