Fokus Posted August 13, 2004 Posted August 13, 2004 (edited) I set up a MySql database on my localhost, and whenevr i run the php to connect to it I get the following message... Warning: mysql_connect(): Access denied for user: 'XXXXXXX_tester@server69.totalchoicehosting.com' (Using password: YES) in /home/XXXXXXX/public_html/directory/config.php on line 2 I cannot connect to the database because: Access denied for user: 'XXXXXXX_tester@server69.totalchoicehosting.com' (Using password: YES) I inserted the proper lables into the php file, localhost is my domain, user and password. I also set up the MySQL and gave access to the user in the error message, but I cannot access, even with the same password I set...no matter how many users I add and change. What am I doing wrong or over looking... Any help would be greatly apprciated. Edited out cPanel name for security. Edited August 13, 2004 by TCH-Rob Quote
TCH-Rob Posted August 13, 2004 Posted August 13, 2004 Let me make sure I have this down. 1. You create DB, named cPanelname_test 2. You create User, named cPanelname_user 3. You add user to DB Your MySQL Account Maintenance screen had something like; DB_name Delete Check Repair Users in DB DB_name (Privileges: ALL PRIVILEGES) Delete Connection Strings Perl $dbh = DBI->connect("DBI:mysql:cPanelname_ivbd1:localhost","cPanelname_dbname","<PASSWORD HERE>"); PHP $dbh=mysql_connect ("localhost", "cPanelname_dbname", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("cPanelname_dbname"); Does that look about right compared to your settings? Quote
Fokus Posted August 13, 2004 Author Posted August 13, 2004 Thanks for your help, i figured out (with some help) that in my config.php file localhost has to stay the same, just as it is recommended in the msql config page. Thanks for the help!!TCH-Rob Quote
TCH-Don Posted August 13, 2004 Posted August 13, 2004 Welcome to the Family Fokus and your new home! We really are like family here. So if you need anything, just ask your new family! We love to help Quote
antz_66 Posted April 18, 2006 Posted April 18, 2006 Let me make sure I have this down. 1. You create DB, named cPanelname_test 2. You create User, named cPanelname_user 3. You add user to DB Your MySQL Account Maintenance screen had something like; DB_name Delete Check Repair Users in DB DB_name (Privileges: ALL PRIVILEGES) Delete Connection Strings Perl $dbh = DBI->connect("DBI:mysql:cPanelname_ivbd1:localhost","cPanelname_dbname","<PASSWORD HERE>"); PHP $dbh=mysql_connect ("localhost", "cPanelname_dbname", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("cPanelname_dbname"); Does that look about right compared to your settings? This is my exact setup sans the Cpanel stuff |-) Totally getting this connection error no matter what I do. Any help is apprciated Quote
TCH-Tim Posted April 18, 2006 Posted April 18, 2006 Welcome to the forums antz. The "cPanel stuff" is only indicating that that's where your cPanel username should be. Database names and database usernames are prefaced by yourCpanelUsername_. Is that what you have? Quote
TCH-Don Posted April 18, 2006 Posted April 18, 2006 Welcome to the forums You need that cpanel stuf to select your database out all the others Here is my database check list -- databse connect ---- Be sure that in MySql you 1 - created the database 2 - created a user 3 -added the user to the database (go back to MySql and find the Add user select the user and database, and then Add user to database) Then to connect to the database in a script use: host: localhost database: yourCpanelName_databaseName user: yourCpanelName_databaseUser password: mypassword * Note password is just as the password, do not add the CpanelName to it. --------------------------- Quote
TCH-JimE Posted April 18, 2006 Posted April 18, 2006 Welcome to the forum, I am glad you have it all working now! JimE Quote
antz_66 Posted April 18, 2006 Posted April 18, 2006 (edited) Hi All, Thanks for the welcome. Basically, I understood what the cPanel stuff was. My setup looks exactly like what Rob had explained. I assumed that the reference to cPanel was similar to "you_name_here" otherwise it looks exactly the same. My issue is even though I've created the db and added the user username_rad (Privileges: ALL PRIVILEGES) Connection Strings Perl $dbh = DBI->connect("DBI:mysql:username_rad:localhost","username_rad","<PASSWORD HERE>"); PHP $dbh=mysql_connect ("localhost", "username_rad", "<PASSWORD HERE>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("username_rad"); I still get this error: Warning: mysql_connect(): Access denied for user: 'username_rad@localhost' (Using password: YES) in /home/username/public_html/mytest/inc/config.php on line 5 I cannot connect to the database because: Access denied for user: 'username_rad@localhost' (Using password: YES) This is what is on line 5 of the config file mentioned above: mysql_connect ("localhost", "username_rad", "username_rad1") or die ('I cannot connect to the database because: ' . mysql_error()); No matter what I do. While I build sites all the time and have worked with established db's this is the first time I've tried to set one up on my own. With that said I'm wondering if it has anything to do with the location of the mySQL db or the placement of the files (which I don't think it does). Thanks to all of you for helping. I really appreciate it. Edited April 18, 2006 by antz_66 Quote
antz_66 Posted April 18, 2006 Posted April 18, 2006 I just realized what Don was saying. DO NOT add the username_ to the password. which in my case and what I posted above was: username_rad1 switched to rad1 It worked perfect. Wow! Nice. Thanks a ton guys. Quote
mbunker Posted August 13, 2007 Posted August 13, 2007 Glad you sorted it out. Hi ! I'm new..... I'd like to reopen the topic. I am trying to connect to a database (that uses Cpanel) from star.hostcolor.us. $dbh=mysql_connect ("localhost", "me_phpbb", "<password here>") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("me_phpbb"); I get a similar message to the above. I cannot connect to the database because: Access denied for user 'me_phpbb'@'localhost' (using password: YES) I have added an access post in the cpanel for both www.totalvibe.universalmusicstudios.com (my url) and star.hostcolor.us my 2nd server. Any thoughts on this? Michele Quote
TCH-Bruce Posted August 13, 2007 Posted August 13, 2007 Hi Michele and welcome to the forums. It doesn't appear that you are hosted with TCH so not sure what help we can offer. On a TCH Server you create a database the name becomes cpaneluser_database-name same with the user for the DB. The cpaneluser_ is pre-pended to the user name. Not sure if your hosting provider has defined it that way or not but maybe their support can point you in the right direction. Also, if you are trying to connect to the database from a different account, you need to use the domain name, not just localhost. Quote
mbunker Posted August 14, 2007 Posted August 14, 2007 thanks for your responces. I am in communication with the techs at my hosting company. Is it OK for me to ask other questions or is this just for Total Choice customers? If it is OK... I'm wondering.... do some hosting companies allow thier databases to be accessed remotely and some not? I am working with 2 hosting companies. one has a place in the cpanel under mysql to add hosts, the other doesn't. The second one says that technically it is not possible because the database has to be on the server that the url is pointing to. Is this always the case? or is it just the case with some hosts because of the way they work? thanks, Michele Quote
TCH-Andy Posted August 14, 2007 Posted August 14, 2007 Welcome to the forum, Michele Yes, it's allowed to ask questions here, it's always best if you point it out though - so we know if you are talking about the setup we have - or what other hosting companies may have. You could of course always come and join the friendly family and host here There is nothing technically to prevent access - but some hosting companies choose not to allow it. Quote
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.