I'm having a minor problem, and I'm hoping someone can help me understand why my system behaves this way. By the way, I'm a MySQL + Terminal newbie, so please go easy on me! I've done some due diligence by reading the MySQL documentation and searching other questions on this site, but I haven't been able to find a good answer to my particular problem.
Steps leading up to the problem:
I've just done a fresh MySQL install using the generic binaries, following the instructions in the MySQL documentation (link). I'm running on Ubuntu Desktop 12.04 (64-bit). MySQL v5.6. After completing the installation instructions, I'm able to start the server, run some basic tests against it, shut it down, and start it back up again, per the post-installation procedures here. This all works fine and dandy.
Description of the problem:
My problem is, after I reboot the host system, when I try to do
$ sudo bin/mysqld_safe --user=mysql & it doesn't prompt me to enter my password for sudo privileges. The impact is the server doesn't start - or at least, it appears not to - I say this because, afterwards, when I do
bin/mysqladmin version it says it could not connect, check that the server is running, yada yada.
This is what it looks like in Terminal:
me@vm-ubuntu:~$ cd /usr/local/mysql me@vm-ubuntu:/usr/local/mysql$ sudo bin/mysqld_safe --user=mysql &  1851 me@vm-ubuntu:/usr/local/mysql$ bin/mysqladmin version bin/mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)' Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists! + Stopped sudo bin/mysqld_safe --user=mysql
and then I get my command prompt back.
Working around the problem:
Here's the interesting part: If I do some other task that involves using sudo, then it prompts me for my password, and after that, I'm able to go back and start MySQL server using the same steps above. For example:
me@vm-ubuntu:/usr/local/mysql$ cd data me@vm-ubuntu:/usr/local/mysql/data$ sudo gedit vm-ubuntu.err
Prompts me to enter my password, which I do. The file opens in gedit, so I close it, and back in Terminal, I change back to the mysql directory and attempt to start the server again using
$ sudo bin/mysqld_safe --user=mysql & and this time, it works (I know this because when I do
bin/mysqladmin version it doesn't fuss at me about the server not running).
So, I can work around the problem, and it's not that big of a deal considering I don't restart the host system very often, but if anyone could help me understand why I don't get prompted for my password the first time I attempt to start the server using
$ sudo bin/mysqld_safe --user=mysql & after rebooting the host system, I'd really appreciate it. I read other similar questions on this site but I did not find one that addresses my particular issue. Thanks!