Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDO MySQL Driver on Mac

I have a mac with a custom PHP 5 install that built from about a year ago. I remember it took all Sunday and I had to compile about 20 times to get it right. The MySQL I have is from entropy and was precompiled.

Now I need to get PDO with the MySQL driver working and the driver is not installed. I tried the "pecl install pdo_mysql" and it dies at a point where it can't find some mysql files. Any ideas how I can fix this quickly?

checking for mysql_config... not found
configure: error: Cannot find MySQL header files under
ERROR: `/private/tmp/pear/temp/PDO_MYSQL/configure' failed

I'll post whatever paths or messages you need to help me troubleshoot this. Will I have to compile PHP all over again, or can I just compile the pdo_mysql extension?

I hope I don't seem lazy, I just have a lot of code to write and not a lot of time to fight with my PHP configuration.

like image 216
Sam McAfee Avatar asked Dec 21 '08 19:12

Sam McAfee


People also ask

Can I use PDO with MySQL?

Unlike MySQLi, PDO is only object-oriented and supports a number of different database types that use PHP, such as MySQL, MSSQL, Informix, and PostgreSQL.

What is a PDO driver?

Introduction ¶ PDO_MYSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MySQL databases. PDO_MYSQL uses emulated prepares by default.

What is MySQL native driver?

MySQL Native Driver is a replacement for the MySQL Client Library (libmysqlclient). MySQL Native Driver is part of the official PHP sources as of PHP 5.3. 0. The MySQL database extensions MySQL extension, mysqli and PDO MYSQL all communicate with the MySQL server.

Does PDO work with MariaDB?

On the other hand, once you've mastered PDO, you can use it with any database you desire, which can be incredibly useful when switching from another database to, say, MariaDB.


1 Answers

You're going to need to compile it by hand, instead of via PECL. You'll need to know where your MySQL install is. I don’t know about the Entropy packages, but the builds provided by MySQL (which I recommend) install into /usr/local/mysql.

$ pecl download pdo_mysql
$ tar xzf PDO_MYSQL-1.0.2.tgz
$ cd PDO_MYSQL-1.0.2
$ phpize
$ ./configure --with-pdo-mysql=/usr/local/mysql
$ make && sudo make install

And that should get you to the point where you can configure it.

like image 68
ieure Avatar answered Sep 17 '22 17:09

ieure