Why am I getting "Unhandled exception: local variable 'pwd' referenced before assignment"?
Asked Answered
E

7

11

I'm trying to transfer a schema from my personal machine to RDS via Workbench. I've exported an SQL dump file and am trying to import it into RDS. However, I get the following error:

Unhandled exception: local variable 'pwd' referenced before assignment

Check the log for more details.

The log file has this:

14:05:01 [WRN][wb_admin_export.py:process_db:277]: Task exited with code 1
14:05:01 [ERR][       pymforms]: Unhandled exception in Python code: 
Traceback (most recent call last):
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 1334, in _update_progress
    r = self.update_progress()
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 913, in update_progress
    self.start()
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 1323, in start
    password = self.get_mysql_password(self.bad_password_detected)
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 963, in get_mysql_password
    if pwd is None:
UnboundLocalError: local variable 'pwd' referenced before assignment

An earlier attempt yielded a little more detail:

14:00:24 [ERR][wb_admin_export.py:process_db:251]: Error from task: ERROR 1045 (28000): Access denied for user 'admin'@'<some_numbers_I_probably_shouldn't_share!>.skybroadband.com' (using password: YES)

14:00:24 [WRN][wb_admin_export.py:process_db:277]: Task exited with code 1
14:00:24 [ERR][       pymforms]: Unhandled exception in Python code: 
Traceback (most recent call last):
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 1334, in _update_progress
    r = self.update_progress()
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 913, in update_progress
    self.start()
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 1323, in start
    password = self.get_mysql_password(self.bad_password_detected)
  File "C:\Program Files\MySQL\MySQL Workbench 8.0 CE\modules\wb_admin_export.py", line 963, in get_mysql_password
    if pwd is None:
UnboundLocalError: local variable 'pwd' referenced before assignment
14:00:43 [ERR][wb_admin_utils.py:page_activated:329]: Exception activating the page - 'Label' object has no attribute 'remove_from_parent'Error from task: ERROR 1045 (28000): Access denied for user 'admin'@'<some_numbers_I_probably_shouldn't_share!> (using password: YES)

This has confused me somewhat as I'm not using Python to transfer anything - I'm using Workbench. Clearly I have a password issue but what is it exactly and how do I fix it? I'm logged into RDS and can add or remove schemas/tables etc manually so Workbench knows what the correct passwords are...

Efthim answered 30/10, 2020 at 14:16 Comment(1)
The python code is part of mysql workbench. You probably stumbled upon a bug, so you should raise this as a bug with mysql.Blowout
S
14

For me, the error is regarding db privilege:

mysqldump: Got error: 1044: Access denied for user 'myuser'@'%' to database 'mydb' when doing LOCK TABLES

You have to uncheck the lock-tables option from the "Advanced Options" available in the top right of the data exporter in MySQL Workbench.

If you're using command to export then add --lock-tables=FALSE flag.

enter image description here

Sandpaper answered 7/2, 2022 at 12:44 Comment(0)
L
2

I had the same problem; this error occurs when you type the wrong password. In my case, I forgot that I was working with the root user so when it asked me for the password I just had to leave the input blank and hit the continue button.

Leonoreleonsis answered 2/10, 2023 at 14:1 Comment(0)
E
1

If you only want to migrate your DB Structure:

  • Open workbench
  • select the connection of your local DB
  • On the left, in the 'navigator' panel choose 'administration'
  • 'Data Export'
  • select the schema you want to export
  • on the right side of the window you should find a 'select box'. switch Dump Structure and Data to Dump Data only

In the same way, select Dump Data only when you will import it!

Honestly, I don't know exactly how it solved the error:

'UnboundLocalError: local variable 'pwd' referenced before assignment ',

but just moving the Structure without the data worked for me.

enter image description here

Enrichetta answered 30/3, 2021 at 11:47 Comment(1)
Thanks loads for this. As I never figured out how to fix this I ditched RDS. However, I'd like to have another go so will report back!!Efthim
E
1

Go to C:\Users\User_Name\AppData\Roaming\MySQL\Workbench\sql_workspaces and delete the workspace of the server where you are getting error, or in easy way, you can delete all folders in sql_workspaces

Ellsworth answered 10/11, 2021 at 21:21 Comment(1)
This actually sorted the error, unlike the other answer's "Dump data only". Thanks!Agni
K
0

I've got the same problem: answers with --lock-tables=FALSE and 'Dump Data only' didn't help in my case.

Workbench gave alert

Unhandled exception: local variable 'pwd' referenced before assignment';

But log tell me 'Access denied for user': workbench error log

Granting all privileges to user solved my problem:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
Kriss answered 20/4, 2023 at 1:35 Comment(0)
C
0

I had the same error while exporting the database, I had to create another user whose host is limited to my pc ip where workbench is installed instead of the %.

Cherycherye answered 25/1 at 8:1 Comment(0)
P
0

None of the provided answers have been able to help me, and although I don't yet have a fix, I have found a workaround.

When you begin the backup process, you'll see the Export Progress window and the associated error message:

Export Progress window and the associated error message

Notice it's use of --defaults-file. That points to a temporary file that contains the plaintext password of the MySQL user.

That's the problem. For some reason, Workbench fails if you try to reference the password through this file.

Here is the workaround:

After dismissing the error dialog, do the following:

  1. copy the command line from the Export Progress window and paste it into a command line window.
  2. Replace the --defaults-file argument with -p (which will allow you to manually enter your password instead of grabbing it from the temporary file).
  3. Add a redirect to your output file at the end of the command line.

Your command line should look something like this (but you'll almost certainly need to change the port number):

mysqldump.exe -p --host=localhost --port=53605 --default-character-set=utf8 --user=root --protocol=tcp --column-statistics=FALSE --skip-triggers "schema_name" > backup.sql

When you hit enter, you'll be asked for your password and the backup will proceed.

Peatroy answered 12/8 at 5:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.