连接到局域网中另一台PC上的mysql服务器 [英] connecting to mysql server on another PC in LAN
问题描述
我在本地网络的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!
- 转到MySQL服务器
- 键入以下代码以授予对其他PC的访问权限:
- Go to MySQL server
- Type the following code to grant access for other pc:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root_password';
FLUSH PRIVILEGES;
用要为其授予访问权限的IP替换%
!
Replace %
with the IP you want to grant access for!
这篇关于连接到局域网中另一台PC上的mysql服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!