To connect to MySQL from another computer, you need the server’s reachable hostname or IP address, a MySQL username and password authorized for your client host, and the configured port. The server must accept TCP/IP connections and the network must allow traffic to that port. For a command-line connection, use mysql -h HOST -P PORT -u USER -p; the client prompts for your password instead of exposing it in the command.
What you need before connecting
Ask the database administrator or hosting provider for the connection details and access requirements. Do not assume that a database is reachable from the public internet, or that it uses the default port.
As an Amazon Associate I earn from qualifying purchases.
- The database hostname or IP address reachable from your computer.
- The MySQL username and password, plus confirmation that the account is allowed to connect from your client’s network or host.
- The configured MySQL TCP port. MySQL’s default is 3306, but a deployment may use another port.
- Any provider-specific access rules, such as an allowlist for your public IP address, a private network or VPN requirement, or instructions for an SSH tunnel.
- If TLS certificate verification is required, the trusted CA certificate file and the expected server hostname.
Connect from the command line
-
Open a terminal on the computer that will run the MySQL client. Confirm that the MySQL command-line client is installed and available as
mysql.Recommended Free Tools
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Run this command, replacing
HOST,PORT, andUSERwith the values supplied by your administrator or provider:#1 Best Overall
mysql -h HOST -P PORT -u USER -pUse uppercase
-Pfor the port; lowercase-pasks for the password. If the server uses MySQL’s default port, you can omit-P PORT. -
Enter the password when prompted. Avoid putting it directly in the command, such as with
-pYourPassword: command-line passwords can be exposed through process information or shell history.Rank #2
-
After connecting, the client displays a MySQL prompt. You can end the session with
exitorquit.The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Check the server, account, and network path
A valid password is only one part of a remote connection. The server must listen on a reachable interface, the network route must permit the connection, and the MySQL account must authorize the connecting host.
Server listening configuration
Remote clients connect over TCP/IP. A server started with skip_networking does not accept network connections. Likewise, if its bind_address is set to 127.0.0.1, it listens only on the local loopback interface and cannot accept remote TCP/IP connections. The administrator should verify the server’s listening configuration and service status; do not change these settings without considering the security consequences.
Firewalls and provider access rules
Check the firewall on the database host, any network firewall between client and server, and the hosting provider’s inbound-access controls. They must permit traffic to the actual configured MySQL port from the client’s network. Some hosted databases have no public endpoint and require a private connection or tunnel instead.
MySQL account host matching
MySQL accounts are associated with both a username and a host, so an account that works on the database machine may not be allowed from your remote computer. Ask the administrator to verify that the account permits connections from your source host and is unlocked. Do not solve an access problem by making the account unrestricted; access should be limited to the hosts and privileges that need it.
Protect the connection with TLS
TLS protects traffic in transit, but encryption and server identity verification are separate protections. In MySQL 8.4, TLS 1.2 and TLS 1.3 are supported. When your provider supplies a CA certificate and a server hostname, prefer a client connection that verifies both the certificate chain and hostname:
Best Value
mysql --host=HOST --port=PORT --user=USER --password --ssl-mode=VERIFY_IDENTITY --ssl-ca=CA_FILE
Replace HOST, PORT, USER, and CA_FILE with the endpoint, configured port, account name, and actual path to the trusted CA certificate. The --password option prompts for the password. Use the hostname that matches the server certificate; connecting by an IP address may fail hostname verification if the certificate does not identify that IP.
--ssl-mode=REQUIRED requires an encrypted connection but does not, by itself, verify the server’s identity. --ssl-mode=PREFERRED can fall back to an unencrypted connection when TLS is unavailable, so it is not appropriate when encryption must be guaranteed. Administrators can enforce encrypted transport server-wide with require_secure_transport or for an account with REQUIRE SSL.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsWhen to use an SSH tunnel instead
If the database should not accept direct inbound connections from your computer, an SSH tunnel may let you reach it through a machine that can access the database. MySQL documents SSH tunneling as an option, including for Windows, but the exact setup depends on the SSH client, tunnel host, and network arrangement. Get the tunnel endpoint and connection instructions from the administrator rather than assuming a command or host.
| Connection approach | Network exposure and access constraints | Where access is routed | Operational considerations |
|---|---|---|---|
| Direct TCP/IP | The database port must be reachable from the client and permitted by host, network, and provider rules. | From the client directly to the database endpoint. | Requires an accessible listening interface and careful firewall rules. Configure TLS verification separately when server identity must be checked. |
| SSH tunnel | Can avoid exposing the database port directly to the client’s network, depending on how the tunnel host and firewalls are configured. | Through an SSH-accessible host that can reach the database. | Requires SSH access and tunnel setup. The available documentation does not establish a universal ranking; TLS certificate verification may still be configured for the MySQL connection. |
Troubleshoot common connection errors
Connection timed out or refused
- Confirm the hostname or IP address and port with the administrator or provider; do not assume the endpoint is public or that it uses port 3306.
- Check that the hostname resolves to the intended server and that the server is running.
- Ask the administrator to check
skip_networkingandbind_address. A loopback-only binding such as127.0.0.1blocks remote clients. - Verify that every relevant firewall and provider access rule permits the client’s source network to reach the configured port.
Access denied
- Check the username and password, and verify that the account is not locked.
- Ask whether the MySQL account’s host component allows connections from the machine or network you are using. Local access does not prove remote access is authorized.
- Do not broaden the account’s host access as a quick workaround; have the administrator grant only the necessary access.
TLS or certificate verification failure
- Confirm that the client and server support a mutually permitted TLS version.
- Check that the CA file is present, readable, and the correct trust certificate for the server.
- With
VERIFY_IDENTITY, use the server hostname that matches the certificate identity; an endpoint mismatch will fail verification.
Unknown host or port
Connection details vary by deployment. Request the actual hostname, configured port, endpoint type, and provider access rules from the administrator instead of guessing them.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




