AquaMorph Posted March 13, 2012 Report Share Posted March 13, 2012 I am using code that looks like this: <?php $db_con = mysql_connect("localhost","root","abc123"); if (!$db_con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("my_data", $db_con); ?> I am trying to connect to a MYSQL Database I made, but the script keeps returning an error "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/teampyro/public_html/scout/config.php on line 2 Could not connect: Access denied for user 'root'@'localhost' (using password: YES)" This is a very noobish question but how should I connect to my database? brierbpromi and hishMaist 2 Quote Link to comment Share on other sites More sharing options...
AquaMorph Posted March 13, 2012 Author Report Share Posted March 13, 2012 Nevermind I figures is out. I need to use my cPanel settings to login. <?php $db_con = mysql_connect("localhost","cpanel_username","cpanel_password"); if (!$db_con){ die('Could not connect: ' . mysql_error()); } mysql_select_db("my_data", $db_con); ?> Quote Link to comment Share on other sites More sharing options...
Tony Posted March 15, 2012 Report Share Posted March 15, 2012 I would advise making a MySQL user and attaching it to the database you wish to use rather than using the cPanel username. You can do this using the MySQL page in cPanel. The reason is if you ever change your cPanel password then you need to update your application configuration to reflect that change. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.