2

I am not able to get drush to work properly:

1) I can download modules & themes through drush but I cannot enable them (more details below). 2) Also I cannot use the omega commands even though they are listed (more details below).

= I installed Composer & Drush as per docs.drush.org/en/master/install/ = Drush is properly installed on my computer, when I type drush version I get: Drush Version : 7.0-dev

My system setup: Linux mint 17 KDE with Xampp 1.8.3-4

I guess my problems are (partly?) caused because Drush was not able to start (bootstrap) the Drupal database. So I run mysql from command line:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

In my system mysqld.sock is in a different location, namely /opt/lampp/var/mysql/mysql.sock. So I created a symbolic link in /var/run/mysqld/ but this has no effect. Still have the same problems. Maybe caused by permissions?

I have spend a few days of and on (had to stop out of frustration) and I cannot get drush to work.

Details of my problems: 1) I can download modules & themes through drush but I cannot enable them:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > drush en disqus
Command pm-enable needs a higher bootstrap level to run - you will need to invoke [error]
drush from a more functional Drupal environment to run this command.
The drush command 'en disqus' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:

bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See drush topic docs-aliases for details.
connect the database through a socket. The socket file may be wrong or the php-cli may have no access to it in a jailed shell. See drupal.org/node/1428638 for details.
Drush was attempting to connect to:
Drupal version : 7.34
Site URI : http://default
Database driver : mysql
Database hostname : localhost
Database port :
Database username : root
Database name : drush
PHP executable : /usr/bin/php
PHP configuration : /etc/php5/cli/php.ini
PHP OS : Linux
Drush version : 7.0-dev
Drush temp directory : /tmp
Drush configuration :
Drush alias files :
Drupal root : /opt/lampp/htdocs/drush
Site path : sites/default

When I add

'host' => php_sapi_name() == 'cli' ? '127.0.0.1' : 'localhost',

or:

'host' => '127.0.0.1',

to settings.php as per this post I get following error:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > drush en disqus
PHP Fatal error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in /opt/lampp/htdocs/drush/includes/database/mysql/database.inc on line 46
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Undefined class constant 'MYSQL_ATTR_USE_BUFFERED_QUERY' in
/opt/lampp/htdocs/drush/includes/database/mysql/database.inc, line 46

2) Also I cannot use the omega commands even though they are listed:

user@mylaptop:/opt/lampp/htdocs/drush/sites/all/modules > drush help --filter=omega
All commands in omega: (omega)
omega-export (oexp) Exports the theme settings of a given theme from the database to the
.info file.
omega-guard (ogrd) Runs guard for the given theme including Compass and LiveReload by
default.
omega-revert (orev) Reverts the theme settings of a given theme by deleting them from the
database.
omega-subtheme Creates a Omega subtheme.
(osub)
omega-wizard (owiz) Guides you through a wizard for generating a subtheme
3

OK I've got drush working:) For other people who might have a similar problem (hope I use the right terms):

I had to install "php5-mysql" (and dependencies) in Linux (for example through "synaptic package manager"), php5-mysql is a MYSQL module for PHP5 which contains mysql PDO support. With this I was able to enable modules and use the omega commands. Drush uses the PHP installed in Linux and not in Xammp, I had this module in Xampp but not in Linux.

You can see which php.ini file drush uses by typing "drush status" in your terminal.

You can see which php.ini file is used by your web server by navigating to admin/reports/status of your drupal site. Next click the "more information" link on Drupal's status page's PHP section. This shows the phpinfo() page. Locate the Configuration File (php.ini).

To check that the mysql PDO support is installed (part of "php5-mysql"), type the following in a terminal: php -i|grep PDO If support is installed you should see something like this: PDO PDO support => enabled PDO drivers => mysql PDO Driver for MySQL => enabled

  • "Drush uses the PHP installed in Linux and not in Xammp" is not very true. – Jimmy Ko Jul 22 '16 at 22:45
  • In my case Ubuntu recently updated to php7.1 and my ansible provisioning was installing php5.6 and php5.6-mysql module. Using drush status showed me that php7.1 was being used for the cli and I just installed php7.1-mysql to fix. No problemo. – Dylan Pierce Jan 18 '17 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.