Software >> Services >> RDBMS >> MySQL >>  How to connect to mysql from command line

 

1. eg. to login to the localhost with user=root and password=xyz and use datatabase DB

> mysql -uroot -pxyz DB

or

> mysql --user=root --password=xyz DB

2. eg. to login to host MyServer with user=root and password=xyz

> mysql -hMyServer -uroot -pxyz DB

or

> mysql --host=MyServer --user=root --password=xyz DB