Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Can't use mysqldiff or mysqlcompare #42

Open
bravecorvus opened this issue Dec 3, 2018 · 3 comments
Open

Can't use mysqldiff or mysqlcompare #42

bravecorvus opened this issue Dec 3, 2018 · 3 comments

Comments

@bravecorvus
Copy link

bravecorvus commented Dec 3, 2018

We are using AWS RDS MySQL version 5.6.10. I have installed mysql-utilities from https://github.com/mysql/mysql-utilities via the manual install method (python2 setup.py install) and the mysql-connector-python package from pip (pip install --user mysql-connector-python). We are trying to see the diff between the 2 databases

Since I am using Python2 and by extension, pip from Homebrew, I had to modify the script a little bit (using /usr/local/bin/python2 rather than /usr/bin/python).

For mysqldiff I am running the command:

mysqldiff \
  --server1='[username1]:[password1]@[servername1].rds.amazonaws.com:3306' \
  --server2='[username2]:[password2]@[servername2].rds.amazonaws.com:3306' \
  --difftype=differ \
  [databasename1]:[databasename2]

For mysqldbcompare, I am running the command:

mysqldbcompare \
  --server1='[username1]:[password1]@[servername1].rds.amazonaws.com:3306' \
  --server2='[username2]:[password2]@[servername2].rds.amazonaws.com:3306' \
  --difftype=differ \
  [databasename1]:[databasename2]

However, I am getting the following errors:

# WARNING: Using a password on the command line interface can be insecure.
Traceback (most recent call last):
  File "./src/mysqldbcompare", line 299, in <module>
    servers = connect_servers(server1_values, server2_values, conn_opts)
  File "/usr/local/lib/python2.7/site-packages/mysql/utilities/common/server.py", line 489, in connect_servers
    source = get_server(src_name, src_dict, quiet, verbose=verbose)
  File "/usr/local/lib/python2.7/site-packages/mysql/utilities/common/server.py", line 336, in get_server
    server_conn.connect()
  File "/usr/local/lib/python2.7/site-packages/mysql/utilities/common/server.py", line 1104, in connect
    res = self.show_server_variable('character_set_client')
  File "/usr/local/lib/python2.7/site-packages/mysql/utilities/common/server.py", line 1391, in show_server_variable
    return self.exec_query("SHOW VARIABLES LIKE '%s'" % variable)
  File "/usr/local/lib/python2.7/site-packages/mysql/utilities/common/server.py", line 1327, in exec_query
    cur.close()
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/cursor.py", line 395, in close
    self._connection.handle_unread_result()
  File "/usr/local/lib/python2.7/site-packages/mysql/connector/connection_cext.py", line 614, in handle_unread_result
    raise errors.InternalError("Unread result found")
mysql.connector.errors.InternalError: Unread result found

Why I think this is a mysql-utilities error:

I tried manually connecting via mysql --host='[servername].rds.amazonaws.com' --user=[username] --password='[password]' --port=3306 and I was able to connect with no errors.

Further info:

MySQL Version: 5.6.10 AWS RDS
Python 2 Version: Python 2.7.15 (from macOS Homebrew)
mysql-utilities Version: 1.6.5
mysql-connector-python Version: 8.0.13

@bravecorvus
Copy link
Author

*hears crickets

@mcouthon
Copy link

mcouthon commented Apr 11, 2019

I've found the issue. Actually, there are 2 issues.
The first is that you need to set a character set by passing something like --character-set utf8 to the command. That's easy.
The second is the more problematic one, and is actually a problem with the connector, not the utilities.
The issue is due to this bit https://github.com/mysql/mysql-connector-python/blob/master/lib/mysql/connector/connection_cext.py#L514

I have a PR up on the mysql-connector-python repo with more technical details.

@bravecorvus
Copy link
Author

Good stuff.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants