Joehoe
Joehoe

Reputation: 213

php fatal error: Undefined class content drush

When I ask the drush status while im in the folder of the website I get this message

/volume1/web/drupal8 $ drush status

PHP Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56

Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56 Drush command terminated abnormally due to an unrecoverable error.
[error] Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php, line 56

When I ask the drush status while im in the bin folder drush seem to work

/bin$ drush status PHP configuration : /etc/php/php.ini PHP OS : Linux Drush script : /usr/local/bin/drush Drush version : 8.1.5 Drush temp directory : /tmp Drush configuration : Drush alias files :

I can't figure out what im doing wrong, how can I run drush on folder /volume1/web/drupal8?

thanks in advance

PDO is installed and enabled. I run php56 -i

PDO PDO support => enabled PDO drivers => dblib, mysql, pgsql, sqlite

pdo_dblib

PDO Driver for FreeTDS/Sybase DB-lib => enabled Flavour => freetds

pdo_mysql

PDO Driver for MySQL => enabled Client API version => mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd 41fc93cccd5bac2fe7a $

Directive => Local Value => Master Value pdo_mysql.default_socket => /run/mysqld/mysqld.sock => /run/mysqld/mysqld.sock

pdo_pgsql

PDO Driver for PostgreSQL => enabled PostgreSQL(libpq) Version => 9.3.6 Module version => 1.0.2 Revision => $Id: 0e858dd2051ca8c2fd3c781909a0670ab5fecd36 $ pdo_sqlite

PDO Driver for SQLite 3.x => enabled SQLite Library => 3.10.2

Upvotes: 1

Views: 3867

Answers (2)

Gilbert M.
Gilbert M.

Reputation: 93

I face this issue as well on all drupal 7 and 8 directory, while drush works fine outside drupal, it doesn't work in Drupal directory. the error says:

Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in Drush\Sql\Sqlmysql->creds() (line 56 of phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php).

Installing php-mysql (or php5-mysql) fix the issue.

Upvotes: 1

Robert
Robert

Reputation: 20286

Probably, you don't have properly installed PDO_MYSQL. You need to invoke phpinfo() function and see if this module is present. The constant MYSQL_ATTR_SSL_CA comes from PDO library. If php is invoked from CLI then probably it has its own php.ini so you need to enable PDO there as well.

To check if you have enabled PDO in PHP CLI run php -m |grep PDO the command should return PDO string.

To install PDO check the PHP Manual for Installing PDO.

Upvotes: 1

Related Questions