How to fix non-root login to MySQL in Ubuntu?

See also: How to set a non-empty password to the root MySQL user in Ubuntu?