To directly login to a remote mysql console, use the below command:
mysql -u {username} -p'{password}'
-h {remote server ip or name} -P {port}
-D {DB name}
For example
mysql -u root -p'root'
-h 127.0.0.1 -P 3306
-D local
no space after -p as specified in the documentation
It will take you to the mysql console directly by switching to the mentioned database.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…