Accessing MySQL Server on Remote PC within LAN
In a local network environment, connecting to a MySQL server on a different PC can be achieved efficiently. Let's delve into the solution:
Initial Connection Attempt Failure
When you encountered the error message "Unknown MySQL server host," it indicated that the connection attempt to the remote MySQL server was unsuccessful. The issue may lie in providing both the host's IP address and port number in the connection string.
To rectify this, remove the port number (3306) from the connection string:
mysql -u user -h 192.168.1.28 -p password
Access Denied Error Due to IP Restriction
The subsequent error message you received, "Access denied," suggests that the user account you are using to connect to the MySQL server does not have the necessary privileges to access the database. By default, MySQL accounts are restricted to connect from specific IP addresses or hostnames.
Granting Access to Remote PC
To resolve this, you need to grant access to your client computer's IP address or hostname on the MySQL server.
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password';
FLUSH PRIVILEGES;
Once you have granted access, you should be able to connect to the remote MySQL server from your client computer.
The above is the detailed content of How to Access a MySQL Server on a Remote PC within a LAN?. For more information, please follow other related articles on the PHP Chinese website!