drush sql-connect
mysql --database=saw_dev --host=localhost --user=sawdev --password=boC,x,o\{w3F\{

DRUSH 4.4
SHELL: /bin/bash

`drush sql-connect`
ERROR 1045 (28000): Access denied for user 'sawdev'@'localhost' (using password: YES)

DRUSH 4.5
SHELL: /bin/bash

`drush sql-connect`
ERROR 1045 (28000): Access denied for user 'sawdev'@'localhost' (using password: YES)

DRUSH 4.5
SHELL: /bin/tcsh

`drush sql-connect`
Missing }.

There was similar bug here:
#1103416: Drush does not correctly shell-escape certain special characters (e.g. in mysql db passwords)
But it seems to be fixed only in 4.4, not in 4.5? (Because I still have escapeshellcmd, instead of drush_escapeshellarg).
Other thing is that my password doesn't contain spaces. Could be problem with something else, as well as with curly brackets as well (in tcsh).

Tested on drush 4.4, now I've latest stable version 4.5

Comments

kenorb’s picture

Issue summary: View changes

added drush version

kenorb’s picture

Issue summary: View changes

added shell info and OS

joelcollinsdc’s picture

I'm hoping to hijack this with a similar issue where I do not really know the solution.

The dev version of drush escapes the password in single quotes if necessary:

mysql --database=db --host=host --user=user --password='!Compl#xP@ssw0rd'

When running this using the $() syntax, this does not work (in bash at least):
set -x;
$(drush sql-connect)
outputs:
mysql --database=db --host=host --user=user '--password='\''!Compl$xP@ssw0rd'\'''

which doesn't work.

I ended up piping the original command through sed to remove the quotes and make this work:
$(drush sql-connect | sed "s/'//g")

Not sure what the right solution is here. Don't do any parameter escaping at all?

kotnik’s picture

Version: All-versions-4.x-dev »

joelcollinsdc, stripping quotes is not a solution, since that'd fail as well if your password contains both spaces and special chars.

kenorb’s picture

Status: Active » Closed (duplicate)

Seems to be fixed in 4.x by following commit:
http://drupal.org/node/1103416#comment-6018870

nrambeck’s picture

I don't want to necessarily open this back up, unless others are still having the same issues, but I am having this same problem with the latest 5.x release.

This happens with passwords that contain special characters. Here is an example: p@33w0rd!

$(drush sql-connect)
ERROR 1045 (28000): Access denied for user 'user'@'host' (using password: YES)

I did find a work-around that I thought might help others. Simply use the eval command.

eval $(drush sql-connect)

or to import a SQL dump

eval $(drush sql-connect) < dump.sql
nrambeck’s picture

Issue summary: View changes

changes in desc

Nkendall’s picture

Version: » 8.x-6.0-rc1
Priority: Normal » Minor
Issue summary: View changes
Status: Closed (duplicate) » Active

Hi all, I recently bumped into this issue with a much more recent version of drush 8.0.0-rcl. I was trying to run 'drush sql-drop -y && drush sqlc < dump.sql" and I was getting the error. This ONLY happened because I had copied my sites folder with a differently configured settings.php, before updating the database. So, I guess drush was using the wrong user for the database query. Just as an FYI.

kenorb’s picture

Status: Active » Closed (duplicate)

Use GitHub instead, see: Mysql SSL / Certificate Support #965, check other issues or create a new one.