In this post, I will explain how to establish connections to the MySQL server, for clients such as MySQL or MySQLdump.
To specify the hostname and user name explicitly, as well as a password, supply appropriate options on the command line.
mysql --host=localhost --user=myname --password mydbname
mysql -h localhost -u myname -p mydbname
Do not insert the password into the command as it will be stored in your cli history. MySQL will prompt you for this after a connection is made. The password is not displayed as you enter it.
This command connects to the server running on
remote.server.com using the default port number (3306):
In some instances you may not be running the MySQL Server on the default port 3306, if you need to specify another port you would use this command:
mysql --host=remote.server.com --port=13306