3

What usually causes this mysqldump error?

exec error: Error: Command failed: mysqldump: Got error: 1066: Not unique table/alias: 'TableFoo' when doing LOCK TABLES
gae123
  • 261
  • 1
  • 2
  • 6
  • Why do you post a question and the answer at the exact same time (2014-08-14 21:06:52Z) ? – RolandoMySQLDBA Aug 22 '14 at 22:02
  • @RolandoMySQLDBA: So that somebody else in the future benefits from my finding. Look at the bottom of a new "Ask Question" form, there is a checkbox that states: "Answer your own question – share your knowledge, Q&A-style" – gae123 Aug 23 '14 at 01:01
  • Someone had this same problem with mysqldump 5 years ago ( http://serverfault.com/q/40362 ) when foo and FOO were interpreted as the same because lower_case_table_names was enabled. Based on your answer below, you simply repeated the database name. – RolandoMySQLDBA Aug 24 '14 at 04:22

1 Answers1

13

A common case for this error is when the same table appears more than one in the mysqldump list of tables:

mysqldump [options] TableFoo  ... TableFoo ...
gae123
  • 261
  • 1
  • 2
  • 6
  • 1
    Is this a solution to your problem? – Vérace Aug 22 '14 at 21:18
  • @Vérace, yes this was the issue in the case I was researching. The mysqldump was generated automatically from code, there was a bug in the code that was generating duplicate entries for some tables. When you have 40 tables it is difficult to spot such an issue. – gae123 Aug 23 '14 at 01:01
  • mysqldump is not the problem. Based on your comment, your code created the problem by giving mysqldump a database name twice. MySQL Error 1066 is invariably caused by human error (http://forums.mysql.com/read.php?10,146444 , http://forums.mysql.com/read.php?10,238919 , http://stackoverflow.com/q/1435177, http://stackoverflow.com/questions/1435177) Just search +mysql +"error 1066" and you will see many more examples of human error. – RolandoMySQLDBA Aug 24 '14 at 04:01
  • i found solution here https://serverfault.com/questions/40362/mysqldump-got-error-1066-not-unique-table-alias-foo-when-using-lock-tables/40371#40371 – shareef Mar 13 '18 at 07:46