Connecting to a MySQL Server on a Remote PC in LAN
You have encountered an issue while attempting to connect to a MySQL database hosted on another computer within your local network. Despite having MySQL installed on your client computer, the connection is failing.
To establish the connection, consider the following steps:
Resolving Unknown Host Error:
You previously executed the command:
mysql -u user -h 192.168.1.28:3306 -p password
However, the port number (3306) should be included after the database address:
mysql -u user -h 192.168.1.28 -p password
Resolving Access Denied Error:
You have successfully connected without specifying the port, but now encounter an access denied error. To resolve this, grant access privileges to the remote computer.
On the server machine where MySQL is running:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.28' IDENTIFIED BY 'root_password';
FLUSH PRIVILEGES;
Additional Notes:
The above is the detailed content of How to Connect to a MySQL Server on a Remote PC in a LAN?. For more information, please follow other related articles on the PHP Chinese website!