MySQL Forums :: Newbie :: Connection Problems


Advanced Search

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 http://dev.mysql.com/doc/mysql/en/Adding_users.html 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


Subject Written By Posted
Connection Problems Richard Walker 11/13/2004 08:44AM
Re: Connection Problems John Lafferty 11/13/2004 01:38PM
Re: Connection Problems Jonathan Stephens 11/15/2004 08:40AM
php5 and mysql connection problem Farad Niftaly 12/10/2004 02:00AM
Re: Connection Problems francis alix 12/12/2004 08:08AM
Re: Connection Problems Claudio Di Ciccio 12/12/2004 03:58PM
could not connect mysql5 from php5 zxcse2010 12/30/2004 01:47AM
Re: could not connect mysql5 from php5 Andre Jacobs 12/31/2004 08:49AM
Re: could not connect mysql5 from php5 deepak saini 04/17/2007 05:29AM
Re: could not connect mysql5 from php5 deepak saini 04/17/2007 05:30AM
CAll mysql stored procedure from php zxcse2010 12/30/2004 01:51AM
Re: CAll mysql stored procedure from php Suresh Nimbalkar 02/27/2006 10:05PM
Re: CAll mysql stored procedure from php rocio mejia 04/21/2007 06:54PM
Re: Connection Problems ben Oude Egbrink 02/04/2006 06:12AM
Re: Connection Problems Godwin Noah 04/18/2007 08:33PM
Connection Problems Wesley George 04/19/2007 08:47AM
Re: Connection Problems mark kinsman 04/19/2007 11:57AM
Re: Connection Problems Ankit Kumar 07/10/2007 04:25AM
undefined function mysql_connect Goran Goran 07/12/2007 06:22AM


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.