Mac OS
This is what worked for me on OS X Yosemite running MySql v5.7 (installed from the .dmg).
cd /usr/local/mysql/bin
mysql -u root -p --connect-expired-password
(Enter the temporary password generated by the installer.)
This gets you into sandbox mode and mysql> prompt. Then set desired root password with SET PASSWORD:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('mySuperSecretPassword');