连接到局域网中另一台PC上的mysql服务器 [英] connecting to mysql server on another PC in LAN

查看:544
本文介绍了连接到局域网中另一台PC上的mysql服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在本地网络的PC上安装了mySQL,如何连接到它?我还在这台计算机上安装了mySQL(我想用它来连接数据库).

I have mySQL setup in a PC on my local network, how do I connect to it? I also have mySQL installed in this computer (which I want to use to connect to the database).

我尝试了以下操作,但不起作用

I tried the following but it's not working

mysql -u user -h 192.168.1.28:3306 -p password
ERROR 2005 (HY000): Unknown MySQL server host '192.168.1.28:3306' (0)

谢谢你的帮助.无论如何,我在没有3306的情况下进行连接,但又遇到了另一个问题. MACBOOK是我的客户端计算机的名称.

Thanks for your help. Anyway, I connect without 3306 and I have another problem. MACBOOK is the name of my client computer.

mysql -u user -ppassword -h 192.168.1.28 
ERROR 1045 (28000): Access denied for user 'user'@'MACBOOK' (using password: YES)

谢谢.

推荐答案

这是一个非常有用的问题!由于我们需要使用集中式数据库运行该应用程序,因此我们应该为LAN中的那台计算机赋予特权,以访问LAN PC中托管的特定数据库.这是解决方案!

That was a very useful question! Since we need to run the application with a centralized database, we should give the privileges to that computer in LAN to access the particular database hosted in LAN PC. Here is the solution for that!

  1. 转到MySQL服务器
  2. 键入以下代码以授予对其他PC的访问权限:
  1. Go to MySQL server
  2. Type the following code to grant access for other pc:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password';

  • 然后输入:

  • then type:

    FLUSH PRIVILEGES;
    

  • 用要为其授予访问权限的IP替换%

    Replace % with the IP you want to grant access for!

    这篇关于连接到局域网中另一台PC上的mysql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆