pt-online-schema-change can't connect with comma in password

Bug #1277049 reported by Fernando on 2014-02-06
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Percona Toolkit
Undecided
Unassigned

Bug Description

Seems that in some step of the DSN building for the DBI connect method the password get cut when it contains a comma.

For example, with password "fizz,buzz", with this command:

pt-online-schema-change --alter "<SOME BASIC ALTER>" --host "<DB HOST>" --user "root" --password "fizz,buzz" --alter-foreign-keys-method "auto" D=test,t=test

It return this:

Cannot connect to MySQL: DBI connect('test;host=<DB HOST>;mysql_read_default_group=client','root',...) failed: Access denied for user 'root'@'<LOCAL IP>' (using password: YES) at /usr/bin/pt-online-schema-change line 2261

And in debug output we can see:

# DSNParser:2210 29539 DBI:mysql:test;host=<DB HOST>;mysql_read_default_group=client
# DSNParser:2259 29539 DBI:mysql:test;host=<DB HOST>;mysql_read_default_group=client root fizz mysql_enable_utf8=>0, ShowErrorStatement=>1, AutoCommit=>1, RaiseError=>1, PrintError=>0
# DSNParser:2259 29539 DBI:mysql:test;host=<DB HOST>;mysql_read_default_group=client root fizz mysql_enable_utf8=>0, ShowErrorStatement=>1, AutoCommit=>1, RaiseError=>1, PrintError=>0
Cannot connect to MySQL: DBI connect('test;host=<DB HOST>;mysql_read_default_group=client','root',...) failed: Access denied for user 'root'@'<LOCAL IP>' (using password: YES) at /usr/bin/pt-online-schema-change line 2261

This is happening with percona toolkit 2.2.6.

Jericho Rivera (jericho-rivera) wrote :

Fernando, can you try the following instead:

pt-online-schema-change --alter "<SOME BASIC ALTER>" --host "<DB HOST>" --user "root" --password "fizz\,buzz" --alter-foreign-keys-method "auto" D=test,t=test

See the "\" before the comma. It worked on my test.

root@node2:/home/vagrant# pt-online-schema-change --user test_user --password "comma\,separated" --alter "ENGINE=InnoDB" D=test,t=t --dry-run
Operation, tries, wait:
  copy_rows, 10, 0.25
  create_triggers, 10, 1
  drop_triggers, 10, 1
  swap_tables, 10, 1
  update_foreign_keys, 10, 1
Starting a dry run. `test`.`t` will not be altered. Specify --execute instead of --dry-run to alter the table.
Creating new table...
Created new table test._t_new OK.
Altering new table...
Altered `test`.`_t_new` OK.
Not creating triggers because this is a dry run.
Not copying rows because this is a dry run.
Not swapping tables because this is a dry run.
Not dropping old table because this is a dry run.
Not dropping triggers because this is a dry run.
2014-02-12T09:27:27 Dropping new table...
2014-02-12T09:27:27 Dropped new table OK.
Dry run complete. `test`.`t` was not altered.

Changed in percona-toolkit:
status: New → Invalid
Fernando (olfativo) wrote :

Yep, it might not be considered as a bug, but at least I think it must be noted in the docs that commas must be escaped in the password argument to this to work, it's not the usual character you might think that can cause troubles.

Changed in percona-toolkit:
status: Invalid → New

This is easy to confirm that pt-* tools works differently than mysql command line client in this case:

[openxs@centos ~]$ pt-online-schema-change --alter "engine=InnoDB" --host=localhost --user=u1 --password=a,b D=test,t=t1
Cannot connect to MySQL: DBI connect('test;host=localhost;mysql_read_default_group=client','u1',...) failed: Access denied for user 'u1'@'localhost' (using password: YES) at /usr/bin/pt-online-schema-change line 2261

[openxs@centos ~]$ mysql --host=localhost --user=u1 --password=a,b -e "select version(), current_user()"
Warning: Using a password on the command line interface can be insecure.
+-------------+----------------+
| version() | current_user() |
+-------------+----------------+
| 5.6.19-67.0 | u1@localhost |
+-------------+----------------+

and manual (http://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html#cmdoption-pt-online-schema-change--password) says nothing about the need to escape comma explicitly. So, this must be either fixed in the tool(s) or clearly documented.

Changed in percona-toolkit:
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers