2 Ways to install Pdo_mysql extensions in PHP _php tutorial

Source: Internet
Author: User
Tags phpinfo zts

2 Ways to install Pdo_mysql extensions in PHP


Method One

Seeing the cakephp documentation requires you to install the pdo_mysql extension, you try to install it.

My system here is CentOS 6.0. If your system is a different version of Linux/unix, you can refer to it. If your system is windows, sorry, the following is not suitable for you, please go.

The first is to download the pdo_mysql extension of the source package. The download page is here: Http://pecl.php.net/package/PDO_MYSQL. You can download it first and then upload it to the server using FTP.

I copied the download address and then downloaded it directly to the server using wget.

# wget Http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

Then the decompression.

# TAR-ZXVF Pdo_mysql-1.0.2.tgz

Enter the extracted directory and execute the phpize.

#/usr/local/php/bin/phpize

Configuring for:

PHP Api version:20100412

Zend Module Api no:20100525

Zend Extension Api no:220100525

The following generates makefile. The following two parameters must be added, I did not add at the beginning, the results are not found in the Php-config and MySQL header files.

#./configure–with-php-config=/usr/local/php/bin/php-config–with-pdo-mysql=/usr/local/mysql

Make a soft connection to the header file of MySQL before making it. Because MySQL installs the time to specify the directory, does not make the soft connection, still cannot find the header file.

# ln-s/usr/local/mysql/include/*/usr/local/include/

Then make and make install.

# make

# make Install

You will then be prompted as follows, meaning that the extension is installed in the following directory.

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-zts-20100525/

For convenience, I moved the pdo_mysql.so file to the extensions directory.

# mv/usr/local/php/lib/php/extensions/no-debug-zts-20100525/pdo_mysql.so/usr/local/php/lib/php/extensions/

You can then modify the php.ini file.

Find Extension_dir = "./" This line, remove the comment, and modify the path.

Extension_dir = "/usr/local/php/lib/php/extensions/"

I tested this and found that PHP only looked for extensions from that directory, not subdirectories in that directory. So I moved the so file to this directory for unified management.

Find Extension=php_pdo_mysql.dll this line, remove the comment, and modify the file name later.

Extension=pdo_mysql.so

File name is not the same, the PHP_ prefix is removed, otherwise the file cannot be found. Behind the DLL is the name of the file under Windows, we changed to so.

The final restart of Apache is possible. Use Phpinfo () to see that the discovery has taken effect.

Method Two

Pdo_mysql the following operations are operating under the Linux system

1, download the file or into the PHP source package into the Ext/pdo_mysql

Http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

2. Unzip the file

Tar zxvf pdo_mysql-1.0.2.tgz

3. Configuring and Compiling files

CD pdo_mysql-1.0.2

/usr/local/php/bin/phpize

./configure–with-php-config=/usr/local/php/bin/php-config–with-pdo-mysql=/usr/local/mysql

Make

Make install

Note: My PHP is installed in:/usr/local/php/mysql installed in:/usr/local/mysql compile the time to pay attention to your own installation directory where

3, installed in the PHP configuration

Keep this in mind and then open the php.ini file,

and add a row

Extension=pdo_mysql.so

Windows PDO mysql extension installation

PHP.ini does not open PDO, so modify the php.ini, the shape as the following code before removing the semicolon, modified as follows:

Extension_dir= "E:/amp/php/ext"//here is configured for your own ext directory path

......

Extension=php_mysql.dll

......

Extension=php_pdo.dll

......

Extension=php_pdo_mysql.dll

After restarting Apache, visit and continue to report the following error:

Cdbconnection Unable to open database connection: Could not find driver

I can not find the database driver, I looked at it again with Phpinfo, PDO is really open, but the database supported in the PDO item shows no value, indicating that the extension cannot be loaded php_pdo_mysql.dll. After several attempts, including replacing the PHP version, replace the MySQL version. But none of them worked. Can't you really start PHP's MySQL PDO extension?

Checked and checked on the internet, and finally found a solution.

Method One: You need to add the path of the PHP installation directory to the system environment variable path, so that the problem can be resolved.

Method Two: Because I am deployed on the server, the server is running, so can not be restarted, it is also possible to copy the PHP installation directory Libmysql.dll under the Windows directory

Restart Apache

http://www.bkjia.com/PHPjc/926229.html www.bkjia.com true http://www.bkjia.com/PHPjc/926229.html techarticle 2 ways to install Pdo_mysql extensions in PHP as soon as you see the cakephp documentation requires you to install the pdo_mysql extension, you try to install it. My system here is CentOS 6.0. If your department is ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.