Enabling MySQL in PHP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Enabling MySQL in PHP

Post by froth »

While configuring phpBB, the install tool told me that MySQL isn't enabled in PHP. I've spent the better part of today installing Perl, PHP, and Python on my new Apache2 server and I guess I just kind of thought that PHP had mysql enabled out-of-the-box. So, what do I add to php.ini (if that's what I do at all) to "enable" mysql in php?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I would guess you installed php5, in which case, that's correct php5 does not support MySQL out of the box. You'll have to either enable the mysql or mysqli api's to get that functionality.
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Post by froth »

Well, all the knowledge I have on the subject is uncommenting items from that list of extensions in php.ini :wink:

A comment in php.ini tells me "Note that MySQL and ODBC support is now built in, so no dll is needed for it."

So... how do I enable it? Is it a special switch somewhere?

And yes, I have all the most updated software (everything was redownloaded and reinstalled this afternoon).
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

php.ini (i want both extensions :))
extension=php_mysql.dll
extension=php_mysqli.dll

in my path (environment variable)
C:\Program Files\mysql\MySQL Server 4.1\bin;C:\Program Files\php-5.0.3-Win32

-> after a reboot everything worked just fine
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Post by froth »

I don't have those DLLs, they didn't come with the installation. Again I say:

"Note that MySQL and ODBC support is now built in, so no dll is needed for it."

Is there some way to enable it without doing the extension=blah.dll thing?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

as we've said, if this is php5, mysql support is NOT built in... no matter what the ini's comments say.

So, is this php5 or php4? Both are currently active and highly available, so we can't tell which one you have installed.
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Post by froth »

yes I have php version 5.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

currently i'm using php5.0.3 and i could nowhere find such a thing on mysql being built in in the php.ini-dist and php.ini-recommended.

the only thing i found, in install.txt (can't find README.txt)
Note: In PHP 4.3.1 BCMath, Calendar, COM, Ctype, FTP, MySQL, ODBC,
Overload, PCRE, Session, Tokenizer, WDDX, XML and Zlib support is
built in. You don't need to load any additional extensions in order
to use these functions. See your distributions README.txt or
install.txt or this table for a list of built in modules.
in snapshot.txt i can't find it either
Built-in Extensions
===========================
bcmath
calendar
com_dotnet
ctype
ftp
iconv
odbc
pcre
session
SPL
SQLite
standard
tokenizer
zlib
libxml
dom
SimpleXML
wddx
xml

The following means you should add a directory to your path where it can find libmysql.dll (%mysql%\bin)
Module: php_mysql.dll
===========================
libmysql.dll

Module: php_mysqli.dll
===========================
libmysql.dll
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Post by froth »

I got it working (finally) by copying php_mysql.dll and php_mysqli.dll (i downloaded them) to c:\windows and c:\windows\system32, as well as the apache ext folder and adding my own extension=php_mysql.dll lines in php.ini... and it seems to be working ok. However, the phpbb installation still hangs. It says that it took 30 seconds to process a mysql line.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

always get the zip distribution of php... because the one with installer doesn't have all those nice extensions etc included (at least i think it doesn't)
froth
Forum Commoner
Posts: 31
Joined: Sat Jan 22, 2005 9:26 pm

Post by froth »

That's right; I had to download the zip to get php_mysql.dll x_x
Post Reply