Welcome to WebmasterWorld Guest from 54.198.183.217

Forum Moderators: open

Message Too Old, No Replies

Cannot connect to mySQL database. Access denied error

Cannot, connect ,to, mySQL ,database, Access, denied ,error

     
2:31 am on Mar 16, 2011 (gmt 0)

New User

5+ Year Member

joined:Mar 16, 2011
posts: 1
votes: 0


I cannot connect to my database and I am unsure as to why.
Hear is the error message:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'tx9271_admin'@'localhost' (using password: NO) in /home/tx9271/public_html/downfeed.com/config.php on line 5
I cannot connect to the database because: Access denied for user 'tx9271_admin'@'localhost' (using password: NO)


Here is the config.php file it is referring to:


<?php
$dbname="tx9271_users";
$host="localhost";
$user="tx9271_admin";
$dbh=mysql_connect ($host,$user,"") or die ('I cannot connect to the database because: ' . mysql_error(). '');
mysql_select_db ("$dbname") or die('I cannot select the database because: ' . mysql_error());

?>



my webhost is hostgator.com. I created the database tx9271_users and created a user in that database called tx9271_admin. If anyone knows what is wrong I would greatly appreciate some help.

Thanks,
tx9271
5:04 am on Apr 16, 2011 (gmt 0)

New User

5+ Year Member

joined:Apr 13, 2011
posts:5
votes: 0


Have you tried adding a password to your user? You could also run these sql commands to make sure your user is set up properly with the way you have it configured.

SET PASSWORD FOR 'tx9271_admin'@'localhost' = '';
GRANT ALL PRIVILEGES ON `tx9271_users` . * TO 'tx9271_admin'@'localhost';

Z
10:51 am on Apr 16, 2011 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10553
votes: 13


typically after granting privileges to a new user you will also have to "mysqladmin reload".
5:04 pm on Apr 18, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


It's highly unlikely most installations allow you to connect with an empty password. If they do, it's highly insecure.