PHP 7 RC3: How to install missing MySQL PDO

后端 未结 12 752
暗喜
暗喜 2020-12-04 11:54

I am trying to setup webserver with PHP 7 RC3 + Nginx on Ubuntu 14.04 (for test purposes).

I installed Ubuntu in Vagrant using

相关标签:
12条回答
  • 2020-12-04 12:37

    First, check if your php.ini has the extension enabled "php_pdo_mysql" and "php_mysqli" and the path of "extension_dir" is correct. If you need one of above configuration, then, you must restart the php-fpm to apply the changes.

    In my case (where i am using the Windows OS in the company, i really prefer OSX or Linux), i solved the problem putting this values in the php.ini:

    ; ...
    
    extension_dir = "ext"
    
    ; ... 
    
    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
    
    ; ...
    

    I hope this helps.

    0 讨论(0)
  • 2020-12-04 12:37

    If you are on windows, and your php folder is not in your PATH, you have set the absolute directory in your php.ini

    for example:

    extension_dir = "C:/php7/ext"
    

    and uncomment

    extension=php_mysqli.dll
    extension=php_pdo_mysql.dll
    

    Restart apache2.4 and it should work.

    I hope it helps.

    0 讨论(0)
  • 2020-12-04 12:38

    I resolved my problem on ubunto 20.4 by reinstalling php-mysql.

    Remove php-mysql:

    sudo apt purge php7.2-mysql
    

    Then install php-mysql:

    sudo apt install php7.2-mysql
    

    It will add new configurations in php.ini

    0 讨论(0)
  • 2020-12-04 12:44
    1. download the source code of php 7 and extract it.
    2. open your terminal
    3. swim to the ext/mysqli directory
    4. use commands:

      phpize

      ./configure

      make

      make install (as root)

    5. enable extension=mysqli.so in your php.ini file
    6. done!

    This worked for me

    0 讨论(0)
  • 2020-12-04 12:44
    ['class' => 'yii\db\Connection',
        'dsn' => 'mysql:host=localhost:3306;dbname=testdb',
        'username' => 'user',
        'password' => 'password',
        'charset' => 'utf8',]
    

    It's simple: Just provide the port number along with the host name and set default sock path to your mysql.sock file path in php.ini which the server is running on.

    0 讨论(0)
  • 2020-12-04 12:46

    For thoses running Linux with apache2 you need to install php-mysql

    apt-get install php-mysql
    

    or if you are running ubuntu 16.04 or higher just running the following command will be enought, no need to edit your php.ini file

    apt-get install php7.2-mysql
    

    If you are running ubuntu 15.10 or below:

    Edit your php.ini file, it's located at /etc/php/[version]/apache2/php.ini and search for pdo_mysql you might found something like this

    ;extension=pdo_mysql.so
    

    Change it to this

    extension=pdo_mysql.so
    

    Save the file and restart apache

    service apache2 restart
    

    Check that it's available in your phpinfo()

    0 讨论(0)
提交回复
热议问题