OK, so I was installing a new piece of server software today. It’s so great that many of these packages now have detailed HOW-TOs (usually in the form of some WIKI) for the lazy admin who just wants to get it up and running. Not that I’m usually lazy, but hey it’s a slow day between Christmas and New Years — I just want to get this installed … so I’m doing the “copy and paste from the HOW-TO thing”.
I came across this line:
“Next we have to create a database which <software> needs to store information:”
$ sudo mysql -u root
No problems, I’ve done that before. I dutifully type that into my shell not thinking much. This is what I get:
$ sudo mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Hrmm. What the heck is “ERROR 1045″ ?! Googling it returns a whole bunch of strange answers.
Turns out this is partly a “RTFM” (read the fine manual) type problem, and partly a “depends how you have MySQL configured” problem. Anyway, if your system allows passwords to be specified at the command line, here is the solution:
You need to add a “-p” after to indicate that you wish MySQL to prompt you for a password.
$ sudo mysql -u root -p Enter password:
Hope this helps the next lazy admin googling it. :-)