LunarMagic Posted June 24, 2003 Share Posted June 24, 2003 I am in the process of moving my site from another host to here. A few of my pages use a mysql database. I created the database, populated it (with a dump from the old one), changed the config files to point to the correct database, but it's giving me an error: >Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'lunarmagic@localhost' (Using password: YES) in /home/lunardr/public_html/index.php on line 46 Couldn't connect to MySQL I'm not really sure what to do about it, since it worked fine on my old site. Could someone please let me know if there's anything I should be doing differently? Here's my connection code... >include('statsconfig.html'); $db = mysql_connect($server, $username, $password); if (! $db) die("Couldn't connect to MySQL"); mysql_select_db($database,$db) or die("Select DB Error: ".mysql_error()); $server is set to "localhost", username and password I set up in the database manually. Thanks. Quote Link to comment Share on other sites More sharing options...
leezard Posted June 24, 2003 Share Posted June 24, 2003 did you assign a username to the database in cpanel? also when you configured it the dbase name should be cpanelusername_dbasename, same way with dbase username. Quote Link to comment Share on other sites More sharing options...
LunarMagic Posted June 24, 2003 Author Share Posted June 24, 2003 Dang, that's the problem... the name of the user. Blech... thanks for your help!! Quote Link to comment Share on other sites More sharing options...
borfast Posted June 24, 2003 Share Posted June 24, 2003 You don't need to create a new user to access the database. Your Cpanel username and password should work just fine. Just a little advice, change the line die("Couldn't connect to MySQL"); into die("Couldn't connect to MySQL: " . mysql_error()); It will provide you with more information on the error. 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.