如何連接區域網路內遠端PC上的MySQL伺服器?

Susan Sarandon
發布: 2024-11-14 11:26:01
原創
467 人瀏覽過

How to Connect to a MySQL Server on a Remote PC in a LAN?

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.

  1. On the server machine where MySQL is running:

    • Open the MySQL command prompt.
    • Execute the following command to grant all privileges to the 'root' user from the remote computer's IP address:
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.28' IDENTIFIED BY 'root_password';
    登入後複製
    • Execute the following command to apply the changes:
    FLUSH PRIVILEGES;
    登入後複製
  2. Replace 'root_password' with the actual root password of the MySQL server.
  3. Replace '192.168.1.28' with the IP address of the client computer (the one from which you want to connect).

Additional Notes:

  • Ensure that the MySQL server is listening on the correct IP address and port.
  • Confirm that your client computer has a firewall that allows connections to the MySQL server.
  • If you continue to encounter issues, check the MySQL documentation or online forums for further troubleshooting solutions.

以上是如何連接區域網路內遠端PC上的MySQL伺服器?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板