I hate getting authentication errors in general. At the worst, authentication errors return as a “wrong password!” popup, becoming a catchall for “I don’t know the error, the server just didn’t like me.” At best, you have ruled out typos, permissions, or just plain “being wrong” and begin the onerous task of sifting through millions of tech forum and stackoverflow questions from people who haven’t ruled out user error, hoping to find the one post from a person whose error code and situation matches yours–and contains a solution.
Here’s hoping my solution helps someone, too.
As most of my readers already noticed, I’m doing a blog overhaul. While updating my WordPress theme to match my analytics goals, I decided the prudent move would be backing up my site database and upgrading WordPress. The auto updates had been giving me errors for awhile, which is not unexpected when I’ve been creating droplets (virtual private servers) like mad to learn new and exciting tricks. I knuckled down last evening to manually upgrade WordPress and hit a wall while backing up my mySQL database.
ERROR 1045: Access denied for user 'root'@'localhost'(using password: YES)
I triple checked my command; it was right. I tried checking the user permissions for the database—also correct. I could log in and out of MySQL without issue and execute any command from inside. I started Googling like mad, returning pages and pages of results for “MySQL 1045 error” that had nothing to do with me. For nearly two hours, I tried changes to my mysqldump command with always the same error. At least it was consistent.
I use DigitalOcean for hosting and adore them not just for reliability and cost, but also for the support community they’ve built. I look to their setup when I have doubts about the direction I’m taking my own tech-oriented communities. I remembered creating this particular droplet with their “one-click WordPress on Ubuntu” install several months ago, and started digging into the DigitalOcean support discussions. I had already ruled out the overall problem being outlined in their documentation, but I was hoping for a hint—and found it in the comment thread for an unrelated issue!
I’d changed my root password during the server setup, but this seemed important enough to check. I rushed to the file and opened it to find that randomly generated password still listed under a “client” section.
Now, Google could help! To the MySQL documentation I went, learning that this .my.cnf file contained usually helpful configurations to save time. I learned the “client” section provides overrides not for MySQL, but obviously any client programs (likely why it was there during install). This default, randomly generated password was overriding the correct (updated during install) password I had to use with mysqldump requests. Once I removed that client password entry—PERFECT!
I hoped this would resolve the automatic WordPress update issue, but no. Thankfully, the DigitalOcean community came to my rescue once more: the wordpress folders weren’t owned by the webserver, which needed–you know, I don’t know at this point. It was almost 1 AM, I was exhausted from the previous error and just grateful to find the solution so quickly.
sudo chown -R www-data /path/to/wordpress (in my case is was /home/wordpress)
It’s possible I totally missed the place I supposed to “look” for all this info, but being new to this I only have error codes to go on.