MySQL – Intermittent ‘Access Denied’ (1045) Message

linuxMySQL

I'm importing a fairly large (100GB+) database from MySQL to PostgreSQL using pgloader. After a seemingly random amount of time the process dies with the following error:

An unhandled error condition has been signalled:
   Failed to connect to mysql at "localhost" (port 3306) as user "USER": MySQL Error [1045]: "Access denied for user 'USER'@'localhost' (using password: YES)"

That user has access to the database both before and after I get the error, so something goofy is going on. Sometimes it happens fairly early in migration. Sometimes it's near the end. Sometimes it happens while copying a table with lots of rows. Sometimes it happens on small tables.

The migration tool opens a new TCP connection for each table, so on a hunch I tried bumping the nofile limit for the mysql user up to 4096. My next attempt completed successfully, but subsequent tests have all failed.

My tests are failing on Ubuntu 14.04 running MySQL 5.5.41. Running the same process on OS X with MySQL 5.6.23 works correctly.

I can't find any errors logged anywhere (mysql error log, syslog or dmesg).

Best Answer

I've experienced problems like this before. It seems to happen when you don't exactly follow the instructions for creating users. There are normally two solutions - perform the operation as root. The other solution is to (re)create your user carefully - but if this is one-off data loading step, then root should be fine.