How to install the MySQL extension in PHP7

Source: Internet
Author: User
Tags deprecated php website

One of the biggest changes relative to PHP5,PHP7 is the removal of the MySQL extension, the recommended use of mysqli or pdo_mysql, in fact, at the beginning of PHP5.5, PHP started to prepare to abandon the MySQL extension, if you use the MySQL extension, you may have seen such a hint " Deprecated:mysql_connect (): The MySQL extension is Deprecated and would be a removed in the Future:use mysqli or PDO Instea D in ". So in future programs, to maintain compatibility, try to minimize the use of MySQL extensions for database connections.

As OPS personnel, both want to use PHP7 to improve the efficiency of the server, but also to ensure that the old program can run, how to do it?

1. Go to PHP website to download MySQL extension, http://Git.php.NET/?p=pecl/database/mysql.git;a=summary

2. Unzip and initialize using the Phpize tool, compile:

  1. #解压

  2. Tar xzvf mysql-45881bd.tar.gz

  3. #进入mysql扩展目录 from www.mfbuluo.com

  4. CD mysql-45881bd/

  5. #使用phpize初始化, my phpize in the/opt/directory.

  6. /opt/php/bin/phpize

  7. #编译mysql扩展, use MySQL native driver as the MySQL link library

  8. ./configure--with-php-config=/opt/php/bin/php-config--with-mysql=mysqlnd

  9. Make && make install

3. Next, we edit the php.ini file directly, copy the mysql.so to PHP.ini Extension_dir, and then add PHP.ini in extension=mysql.so

4. Restart PHP

After success, you can see the MySQL extension information with phpinfo:


How to install the MySQL extension in PHP7

Related Article

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.