By walterbays on Dec 09, 2007
After installing MySQL on Ubuntu 7.10 (Gutsy Gibbon) I couldn't connect to the database. Usually MySQL is installed with a blank root password which you should immediately change. Here the package I installed already had the password set to something, but what? I found many blog and forum postings telling how to change the password - assuming you already knew it. And I found many saying that you would be prompted for an initial password when you installed it. Not so for me.
I found the solution that worked at linuxweblog, posted by sandip. You start the safe daemon with an option to disable grant tables, and set the password. Don't forget to kill the safe daemon and restart MySQL normally.