Skip to content
This repository was archived by the owner on Sep 8, 2021. It is now read-only.
This repository was archived by the owner on Sep 8, 2021. It is now read-only.

PDO : Uncaught PDO exception: could not find driver #65

Description

@StephenKirwin

I used this layer to create a PHP lambda API. I then tried to create a PDO and connect it to a MySQL database. I got the following error
"Uncaught PDOException: could not find driver in /var/task/index.php"

My php.ini file contains the following:
extension=json.so
extension=mysql.so
extension=pdo_mysql.so
extension=pdo.so
extension=php_pdo_mysql.dll
extension=pdo_mysql.dll

Here is my index.php code for creating the DB
$conn = null;

$conn = new PDO('mysql:host=' . $host . ';dbname=' . $db_name, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

Activity

  1. czerniachowicz commented on Aug 30, 2020

    @czerniachowicz

    I'm seeing the same or similar, its not that it can't find the extension but it doesn't seem to be compiled properly:

    undefined symbol: mysqlnd_allocator

    [Sun Aug 30 20:24:07 2020] PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /opt/lib/php/7.3/modules/pdo_mysql.so (/opt/lib/php/7.3/modules/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /opt/lib/php/7.3/modules/pdo_mysql.so.so (/opt/lib/php/7.3/modules/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 |  

    Any thoughts?

  2. czerniachowicz commented on Aug 31, 2020

    @czerniachowicz

    The solution is quite simple actually, in your php.ini reorder your extensions so that the mysqlnd is loaded first, and any mysql related extensions are last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions