To login to MySql database from a commend line you can use
mysql -u root -p;
after hitting enter system will ask you for the password or you can use this command
mysql -u root -pPassword;
Once login to the database you have to select the database to work with.