MySQL Forums
Forum List  »  Newbie

Re: could not connect mysql5 from php5
Posted by: Andre Jacobs
Date: December 31, 2004 08:49AM

Hey man,

How was the mysql install compiled? If you compiled php5 without the necessary mysql support, your code will reveal nothing... Below is how I compiled php5:

./configure --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-apache=../apache_1.3.29 --enable-track-vars

This builds with the advanced mysqli call to database as well as the old mysql call.

If you did infact include those statements in you build. What you could do is place || die (mysql_error()); at the end of your connection statement, to get more info..

$dbcnx = @mysql_connect('localhost', 'root', 'root') || die (mysql_error());

Chk your grant table privileges.. If you are connecting to the webserver and database from a remote machine and cannot connect, you probably need to add another user alias to the grant tables.. You need user@localhost and user@% . The later is the one you need if you are connecting from another workstation. Here are the commands in mysql..

mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost'
-> IDENTIFIED BY 'some_pass' ;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'%';

Chkout for more info.

One more thing.. It seems like your connect statement looks odd. I have never seen it that way with the @ before the mysql.. I connect using followning code.

@ $db = mysqli_connect(blah, blah, blah);

That could me messing you up, not sure though.. I am new to php and mysql..
One more thing, create alternate users and not 'root'..

Options: ReplyQuote

Written By
November 13, 2004 08:44AM
November 13, 2004 01:38PM
November 15, 2004 08:40AM
December 12, 2004 08:08AM
December 12, 2004 03:58PM
December 30, 2004 01:47AM
Re: could not connect mysql5 from php5
December 31, 2004 08:49AM
February 04, 2006 06:12AM
April 18, 2007 08:33PM
April 19, 2007 08:47AM
April 19, 2007 11:57AM
July 10, 2007 04:25AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.