The command:
mysql -u root -p
gives the error:
ERROR 1698 (28000): Access denied for user \'root\'@\'localhost\'
>
Only the root user needs sudo requirement to login to mysql. I resolved this by creating a new user and granting access to the required databases:
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'newuser'@'localhost';
now newuser can login without sudo requirement:
mysql -u newuser -p