Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot connect to MySQL database

Status
Not open for further replies.

al042077

Technical User
Joined
Sep 2, 2003
Messages
1
Location
US
Well, I have MySQL 4.1 up and running on Red Hat 9. I can use the command line interface to connect, run queries, etc. I have PHP up and running as shown by running a phpinfo().

In my PHP page, I have:
$h = mysql_connect($host, $user, $pass);
$d = mysql_select_db($db);


I know the server connection is getting established because $h is true, but I keep getting access denied errors and $d is false. I double-checked the name of the database, and it matches. Also, the user should have rights because I set the user with
GRANT ALL ON * TO username IDENTIFIED BY password
and then changed any 'N' to 'Y' for priveleges in the user table of the mysql database. Thoughts??
 
Try to add errorchecking that returns what MySQL said:
Code:
$h = mysql_connect($host, $user, $pass) or die(mysql_error());
$d = mysql_select_db($db) or die(mysql_error());

The denial message will be more verbose and help track down what's going on.

 
MySQL user credentials aren't just a doublet of userid/password. They're a triplet of userid/password/IPaddress.

You need to insure that the username can connect from the host you've specified.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Also as redhat 9 has lots of security additions (ipchians /firewaling) you need to ensure that you have access priveleges to the mysql socket.

xinetd gets more complicated every time I look at it, so I suggest understanding(or turning off if safe to do so) the standard RH9 firewall

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top