Home  >  Article  >  Backend Development  >  How to add mysql extension to php

How to add mysql extension to php

藏色散人
藏色散人Original
2021-12-14 09:30:393026browse

How to add mysql extension to php: 1. Install libxml, openssl, mysql, mysql-devel, etc. through yum; 2. Modify "--with-mysql=/usr".

How to add mysql extension to php

The operating environment of this article: CentOS release 5.8 system, PHP version 5.6, Dell G3 computer.

How to add mysql extension to php?

php Add mysql extension:

os: CentOS release 5.8 (Final)

php version: http://cn2.php .net/distributions/php-5.6.18.tar.gz

First use yum to install libxml, openssl, mysql, mysql-devel, etc.

I searched the Internet for the configure command as follows

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr --with-mysql=/usr/include/mysql --with-mysqli=/usr/bin/mysql_config --with-libxml-dir=/usr/local/libxml2 --with-openssl

Error report:

Cannot find MySQL header files under /usr/include/mysql

I tried various explanations on the Internet, but none of them worked. Then I directly looked at the configure file and why it was old. Report like this,

So first grep 'error: Cannot find MySQL header files under' configure -n

I found the place where this log appeared:

./configure:

fi

if test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL" = "mysqlnd"; then
    PHP_MYSQLND_ENABLED=yes

elif test "$PHP_MYSQL" != "no"; then
  MYSQL_DIR=
  MYSQL_INC_DIR=

  if test -r $PHP_MYSQL/include/mysql/mysql.h; then
    MYSQL_DIR=$PHP_MYSQL
    MYSQL_INC_DIR=$PHP_MYSQL/include/mysql
    break
  elif test -r $PHP_MYSQL/include/mysql.h; then
    MYSQL_DIR=$PHP_MYSQL
    MYSQL_INC_DIR=$PHP_MYSQL/include
    break
  fi

  if test -z "$MYSQL_DIR"; then
    { { $as_echo "$as_me:$LINENO: error: test Cannot find MySQL header files under $PHP_MYSQL.
Note that the MySQL client library is not bundled anymore!" >&5
$as_echo "$as_me: error: hgyang Cannot find MySQL header files under $PHP_MYSQL $MYSQL_DIR.
Note that the MySQL client library is not bundled anymore!" >&2;}
   { (exit 1); exit 1; }; }
  fi

Your sister ah! ! !

It turns out that --with-mysql=/usr is enough, include/mysql has been included, and I burst into tears instantly, what a big pitfall.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to add mysql extension to php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn