Home > Database > Mysql Tutorial > body text

How to Access a MySQL Server on a Remote PC within a LAN?

Mary-Kate Olsen
Release: 2024-11-08 02:14:01
Original
128 people have browsed it

How to Access a MySQL Server on a Remote PC within a LAN?

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
Copy after login

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.

  1. Connect to the MySQL server.
  2. Execute the following command:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password';
Copy after login
  1. Replace % with the IP address of your client computer.
  2. Execute:
FLUSH PRIVILEGES;
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!