ERROR 1044 (42000): Access denied for user ‘’@’localhost’ to database ‘whatever’

Árpád Tamási
samebug
Published in
1 min readDec 6, 2017

I still don’t understand what really happened. I created a user in MariaDB, granted all rights and my app did not get access.

This is the stacktrace I got:

Note that the username is empty. It wasn’t actually. So I tried to fix the configuration and debugged why it does not read the username from it. It was perfect, but the app did not work.

30 minutes passed.

I tried to log in from the console. I did not get access either. Dropped and created the user some times, each time with different host, granted the rights again. Nothing worked.

Another 30 minutes passed.

Then after some hopeless Googling I found this answer for a different problem: https://stackoverflow.com/a/21744960

It told that MySQL can authenticate you as a different user from what you used to log in.

I was able to log in with my user without specifying the database, and bingo USER() and CURRENT_USER() were different:

I logged in as samebug and got authenticated as nobody.

Another 30 minutes passed.

I queried the user table in mysql, I found two users without a username, created automatically during the installation (OSX, MariaDB, homebrew). Deleted them and now I can log in and the app works like a charm.

I wrote this post just to ventilate.

Another 15 minutes passed.

I still don’t understand what happened. It got fixed, anyway.

Almost two hours passed altogether.

--

--