Bug #80240 MySQL Workbench error when trying to export data
Submitted: 2 Feb 2016 18:20 Modified: 18 May 2016 19:10
Reporter: Peter Curtis Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S2 (Serious)
Version:6.3.6 OS:Windows (Windows 7)
Assigned to: CPU Architecture:Any
Tags: Data Export, self not defined

[2 Feb 2016 18:20] Peter Curtis
Description:
What I did:
- logged in to a remote database
- selected Server --> Data Export

What I wanted to happen: export table data.

What happened: MySQL Workbench Error: "An unhandled exception occurred (global name 'self' is not defined). Please refer to the log files for details.

Error Log:

11:16:03 [ERR][wb_admin_main.py:tab_changed:211]: Unhandled exception in Admin for <wb_admin_export.WbAdminExport; proxy of <Swig Object of type 'mforms::Box *' at 0x0D940260> >: Traceback (most recent call last):
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_main.py", line 208, in tab_changed
    panel.page_activated()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 2255, in page_activated
    self.create_ui()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 2308, in create_ui
    self.options_tab = WbAdminExportOptionsTab(self.ctrl_be.target_version, self.export_tab.mysqldump_defaults)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 1997, in __init__
    mysqldump_version = get_mysqldump_version()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 119, in get_mysqldump_version
    self.print_log_message("Could not parse version number from %s:\n%s"%(path, output))
NameError: global name 'self' is not defined

11:16:05 [INF][wb_admin_control.py:server_polling_thread:540]: Monitoring thread running...
11:16:06 [ERR][wb_admin_main.py:tab_changed:211]: Unhandled exception in Admin for <wb_admin_export.WbAdminExport; proxy of <Swig Object of type 'mforms::Box *' at 0x0D940260> >: Traceback (most recent call last):
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_main.py", line 208, in tab_changed
    panel.page_activated()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 2255, in page_activated
    self.create_ui()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 2308, in create_ui
    self.options_tab = WbAdminExportOptionsTab(self.ctrl_be.target_version, self.export_tab.mysqldump_defaults)
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 1997, in __init__
    mysqldump_version = get_mysqldump_version()
  File "C:\Program Files (x86)\MySQL\MySQL Workbench 6.3 CE\modules\wb_admin_export.py", line 119, in get_mysqldump_version
    self.print_log_message("Could not parse version number from %s:\n%s"%(path, output))
NameError: global name 'self' is not defined

How to repeat:
log in to a remote database
select Server --> Data Export

Suggested fix:
unknown.
[3 Feb 2016 15:54] MySQL Verification Team
Thank you for the bug report. The user privileges connected with the remote server has restricted privileges? i.e: granted only the database which you want to export data?. Thanks.
[3 Feb 2016 16:49] Peter Curtis
Don't really understand the last comment.  What I can say is that the export feature worked before I upgraded MySQL workbench.  Afterwards, I began receiving the error message.  I receive the same error if I connect to my localhost MySQL account.  It does not seem to be related to a specific database or database connection.
[16 Feb 2016 16:04] Jack David Baucum
I am also getting this with MySQL Workbench 6.3 build 511 CE 64-bit. I am running this on Ubuntu 15.10.

Here are the relevant portions of the error log generated with --log-level=debug3

11:01:15 [DB1][wb_admin_control.py:add_event_handler:70]: Added WbAdminControl for event server_started_event
11:01:15 [DB1][wb_admin_control.py:add_event_handler:70]: Added WbAdminControl for event server_stopped_event
11:01:15 [INF][     SSH tunnel]: Existing SSH tunnel found, connecting
11:01:15 [DB2][sshtunnel.py:notify:228]: tunnel_12515: INFO New client connection
11:01:15 [DB2][sshtunnel.py:notify:228]: tunnel_12515: INFO Client connection established
11:01:15 [DB2][sshtunnel.py:notify:228]: tunnel_12515: INFO Tunnel now open ('127.0.0.1', 39956) -> ('50.116.45.38', 22) -> ('pithos', 3306)
11:01:15 [DB1][wb_admin_control.py:__init__:109]: Constructing SQL query runner, dbconn (<workbench.db_utils.MySQLConnection instance at 0x7f12ed63a680>)
11:01:15 [DB1][wb_admin_control.py:exec_query:131]: Executing query SHOW VARIABLES
11:01:15 [DB1][wb_admin_control.py:exec_query:131]: Executing query SHOW GLOBAL STATUS
11:01:15 [INF][wb_admin_control.py:query_server_info:690]: WbAdminControl.connect_sql(): The server version stored in the server instance profile was "5.5.46-0ubuntu0.12.04.2". Changed to the version reported by the server: "5.5.47-0ubuntu0.12.04.1"
11:01:15 [DB1][wb_admin_control.py:exec_query:131]: Executing query SHOW PLUGINS
11:01:15 [DB1][wb_admin_control.py:add_event_handler:70]: Added AdministratorTab for event server_started_event
11:01:15 [DB1][wb_admin_control.py:add_event_handler:70]: Added AdministratorTab for event server_stopped_event
11:01:15 [INF][     SSH tunnel]: Existing SSH tunnel found, connecting
11:01:15 [DB1][wb_admin_main.py:__init__:146]: WBA init complete
11:01:15 [WRN][   mforms.linux]: Unknown column storage typeUnknown column storage typetunnel_12515: INFO New client connection
11:01:15 [DB2][sshtunnel.py:notify:228]: tunnel_12515: INFO Client connection established
11:01:15 [ERR][wb_admin_main.py:tab_changed:211]: Unhandled exception in Admin for <wb_admin_export.WbAdminExport; proxy of <Swig Object of type 'mforms::Box *' at 0x7f12ec68a9f0> >: Traceback (most recent call last):
  File "/usr/lib/mysql-workbench/modules/wb_admin_main.py", line 208, in tab_changed
    panel.page_activated()
  File "/usr/lib/mysql-workbench/modules/wb_admin_export.py", line 2255, in page_activated
    self.create_ui()
  File "/usr/lib/mysql-workbench/modules/wb_admin_export.py", line 2308, in create_ui
    self.options_tab = WbAdminExportOptionsTab(self.ctrl_be.target_version, self.export_tab.mysqldump_defaults)
  File "/usr/lib/mysql-workbench/modules/wb_admin_export.py", line 1997, in __init__
    mysqldump_version = get_mysqldump_version()
  File "/usr/lib/mysql-workbench/modules/wb_admin_export.py", line 103, in get_mysqldump_version
    self.print_log_message("mysqldump command was not found, please install it or configure it in Edit -> Preferences -> MySQL")
NameError: global name 'self' is not defined

11:01:16 [DB1][wb_admin_control.py:event:94]: Found event server_started_event in list
11:01:16 [DB2][sshtunnel.py:notify:228]: tunnel_12515: INFO Tunnel now open ('127.0.0.1', 39958) -> ('50.116.45.38', 22) -> ('pithos', 3306)
11:01:16 [DB1][wb_admin_control.py:event:97]: Passing event server_started_event to WbAdminControl
11:01:16 [DB1][wb_admin_control.py:event:97]: Passing event server_started_event to AdministratorTab
11:01:17 [INF][wb_admin_control.py:server_polling_thread:540]: Monitoring thread running...
[16 Feb 2016 16:07] Jack David Baucum
Like Peter Curtis, I find Miguel Solorzano's comment to be rather nonsensical. This worked on previous versions of MySQL Workbench, and there certainly are not any relevant permission restrictions for the user I am connecting with.
[17 Feb 2016 0:32] MySQL Verification Team
user with only privileges on schema h

Attachment: restricted.png (image/png, text), 208.49 KiB.

[17 Feb 2016 0:34] MySQL Verification Team
@Jack David Baucum. Please see prior attached screenshot when user with restricted privileges wants to export data for the schema which has fully privileges only. Thanks.
[17 Feb 2016 14:04] Jack David Baucum
@Miguel, I must be missing something here. I do not understand what the screenshot you posted has to do with the bug that Peter and I are reporting. Neither one of us reported any error related to the screenshot you posted.

I have rolled back to a previous version of MySQL Workbench and exports work again. If there was a database permission issue with doing exports, then it would not work in any IDE, since it would be the database denying the request. Since it works in the previous version of MySQL Workbench (6.3.4.0) and I can do exports again.
[17 Feb 2016 14:49] Jack David Baucum
Error Message

Attachment: workbench.png (image/png, text), 85.02 KiB.

[17 Feb 2016 14:53] Jack David Baucum
Looking at the stack trace we can see the cause of this error:
self.print_log_message("mysqldump command was not found, please install it or configure it in Edit -> Preferences -> MySQL")

This actually has nothing to do with the version of MySQL Workbench, but is a function of the tools installed. I must have installed mysql-client before I reverted back to the older MySQL Workbench. The real issue here is that MySQL Workbench gives a bogus message on the screen, but the real message shows up on the terminal.
[17 Feb 2016 15:07] Jack David Baucum
I did some more digging and the problem is a little more basic. In the file wb_admin_export.py, there are four functions defined at the top of the file. The last two, get_path_to_mysqldump and get_mysqldump_version have calls to self. Since these functions are not methods on a class, there is no self to reference, hence the error, "global name 'self' is not defined". These functions either need to use an alternate method to write to the log, or should be moved into a relevant class.
[17 Feb 2016 15:08] MySQL Verification Team
What I wanted to show you (I didn't know could cause a data export at that time) that the user which connect with privileges only for the schema to be exported could cause an error, that don't meant is the cause of this bug but instead a process to investigate the cause.
[5 Mar 2016 23:49] miljenko test
I had similar issue - exception when trying to open export data (see log file below)
The root cause in my case was "no-beep" option in [client] section instead of [mysql].
So I am posting this to help others.
To check if you are affected - type "sqldump" on command prompt.
If you get "mysqldump: [ERROR] unknown option '--no-beep'", then move no-beep option from [client] to [mysql] (in my.ini or whatever option file you are using).

Comments to the maintainer
1) error is misleading (as one of the previous users reported)
2) please fix no-beep option bug (I have vanilla installation)
3) many thanks for the good work and support

excerpt from wb.log
wb_admin_export.py", line 113, in get_mysqldump_version
    self.print_log_message("Error retrieving version from %s:\n%s (exit %s)"%(path, output, rc))
NameError: global name 'self' is not defined
[18 May 2016 19:10] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Workbench 6.3.7 release, and here's the changelog entry:

When executing Data Export using a remote MySQL connection, the error
resulting from a missing mysqldump binary was unclear.

Thank you for the bug report.