How to login in MySQL through Command Prompt?




A user can login in MySQL through command prompt using the below command:

First Way : MySQL Login

mysql> mysql -u username -p
Enter password:******

-u refers to username flag and is followed by username
-p refers to password flag and is followed by password in next line

Second Way : MySQL Login

mysql> mysql -u username -ppassword

-u refers to username flag and is followed by username
-p refers to password flag and is followed by password

Please note in this case that there is no space between -p and password in the second approach. Also note that the second approach is not recommended as the password becomes visible.