I was working with a local drupal instance and watned to manage it with drush (4.0 HEAD) . I got that funky SQLSTATE warning as shown
yuval@jinbocho:/srv/sites/udch6workflow/blog$ ./drush status
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [warning]
Drupal version : 6.4
Site URI : http://udch6workflow:10105
Database driver : mysqli
Database hostname : localhost
Database username : yuval
Database name : udch6workflow
Default theme : garland
Administration theme : garland
PHP configuration : /usr/local/zendphp52/zend/etc/php.ini
Drush version : 4.0-dev
Drush configuration : /home/yuval/apps/drush/drushrc.php
Drupal root : /srv/sites/udch6workflow/blog
Site path : sites/default
Here's the drushrc.php i used:
// Drupal root directory to use.
$options['r'] = '/srv/sites/udch6workflow/blog';
// URI of the drupal site to use.
$options['l'] = 'http://udch6workflow:10105';
//
$options['u'] = 'yuval';
// Load a drushrc.php configuration file from the current working directory.
$options['c'] = '.';
// Specify additional directories to search for *.drush.inc files
// Use POSIX path separator (':')
//$options['i'] = 'includes/';
either way, i tracked down the error complaint to drush/includes/environment.inc and found that if i adjusted the $type line like so the warning went away:
$type = ($creds['driver'] == 'mysqli') ? 'mysqli' : $creds['driver'];
A patch with this attachment is attached below.
Is the patch fixing something or did I just miss something? :)
Thanks!
Yuval
Comment | File | Size | Author |
---|---|---|---|
drush_type_mysqli.patch | 943 bytes | yuvilio |
Comments
Comment #1
drewish CreditAttribution: drewish commentedSeems like based on your experience that the line should just be removed entirely. Since it's turning into a no-op in your case.
Comment #2
greg.1.anderson CreditAttribution: greg.1.anderson commentedYes, the patch is the same as removing the modified line. I'm not sure why the original code switches from 'mysqli' to just 'mysql', or what the affect for others would be if this modification was removed. I'm guessing that it's not a good idea.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedI ran into this issue when running updb. Every other Drush command was fine, except updating the database. The quick fix for me was to simply make a symbolic link from my mysql.sock file (/Applications/MAMP/tmp/mysql/mysql.sock) to /var/mysql/mysql.sock. For certain commands, Drush wants the socket file to be located in /var/mysql
Comment #4
jonhattanAt present the code does not use PDO (#571352: false positives verifying database credentials in validation of DRUSH_BOOTSTRAP_DRUPAL_DATABASE) and looks like:
I was lazy to add explicit mysqli support. Test with HEAD version. If it doesn't work I'll move to implement the mysqli case.
Comment #5
jonhattanmysqli support was already implemented: http://drupal.org/node/571352#comment-3856212
Comment #7
hass CreditAttribution: hass commentedThis bug is back. For me drush worked well with 4.x and not with 5.x it's broken. I'm in a jailed linux shell and I do not have permission to access mysqld.sock. This worked all flawless in past and the database is configured and running :-). The update module is also enabled and works in the website.
Comment #8
hass CreditAttribution: hass commentedI also believe that
%paths : Array
is a bug, too.Comment #9
hass CreditAttribution: hass commentedMysql should not use the sock way by default as this may not allowed in jailed environments. -h must work always with the configured site settings or the site would otherwise not work.
Comment #10
greg.1.anderson CreditAttribution: greg.1.anderson commentedA patch that fixed the problem would be very useful.
Comment #11
jonhattanIt seems your jailed shell has no access to the mysql socket file. I don't see the relation with mysqldump and -h cli option since the problem happens when drush tries to connect the database, with php. Also it already passes the hostname to the connection function. See drush_valid_db_credentials()
"localhost" means socket connection. To use tcp/ip hostname must be 127.0.0.1(*). So I don't see how it was working for you with drush 4.x and not with 5.x. Anyway the difference between 4.x and 5.x in this respect is the addition of support for unix_socket added in #437642: support for different MYSQL socket. Is this related to your setup?
(*) reference issue #1428638: Forcing 127.0.0.1 instead of localhost for drush
Comment #12
hass CreditAttribution: hass commentedThe reason that it no longer works is my hoster has limited the permissions to socks file. In past I had permission and now he suggested to use the IP address with
-h 127.0.0.1
. I was not aware that localhost is a special case for mysql dump.Like the original reporter, who has 100% the same situation (localhost) including the same error message, I'm verbose now, we should configure Drupal to use "127.0.0.1" for the database connection and NOT "localhost. I'm fine with this, but it's something that should be documented!
The better would be if Drush adds the special case documented in #1428638: Forcing 127.0.0.1 instead of localhost for drush.
Comment #13
jonhattanI agree we should add some notice in the error output near this:
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does not have a configured database.
perhaps show the message conditionally based on the error number and/or hostname = localhost.
Comment #14
jonhattanAdded a message with reference to #1428638: Forcing 127.0.0.1 instead of localhost for drush
http://drupalcode.org/project/drush.git/commit/432713f