To connect to MySQL from the command line in a Mac
You need to run this code,
mysql -u USERNAME -pPASSWORD -h HOSTNAMEORIP DATABASENAME
The meaning of above code is this:
-u: username
-p: password
-h: host
The last one is the name of the database that you wanted to connect.