Accessing Remote MySQL Database from Command Line
When attempting to connect to a remote MySQL database from the command line, it's common to encounter errors like "ERROR 2003...Can't connect to MySQL server on '{server address}'".
To resolve this issue, authenticate to the database using the correct syntax:
mysql -u {username} -p'{password}' \ -h {remote server ip or name} -P {port} \ -D {DB name}
Here's an example:
mysql -u root -p'root' \ -h 127.0.0.1 -P 3306 \ -D local
Key Points:
By following these steps, you should be able to successfully connect to the remote MySQL database from the command line.
The above is the detailed content of How Do I Connect to a Remote MySQL Database from the Command Line?. For more information, please follow other related articles on the PHP Chinese website!