[英]Connect to MySql using IP address
I have written some code and am currently running it using loachost however am trying to set it up so that I can run the app from other computers, I am using MySql and after searching online I found that if I replace "localhost" with my IP address (found from google) for the host name on MySql I will be able to connect from other machines, I tried this and got an error saying that I cannot connect to the server and listed some checks: 我已经编写了一些代码,当前正在使用loachost运行它,但是试图将其设置为可以从其他计算机上运行该应用程序,我正在使用MySql,并且在在线搜索后发现,如果我用IP替换了“ localhost” MySql上主机名的地址(从google找到),我将能够从其他计算机连接,我尝试了此操作,但收到一条错误消息,说我无法连接到服务器并列出了一些检查:
Check that MySql is running on the servr - how do I check this? 检查MySql是否在服务器上运行-如何检查?
Check that MySql is running on port 3306 - I changed this to 3307 when making the database however, I tried both and got the same errors. 检查MySql是否在端口3306上运行-创建数据库时,我将其更改为3307,但是,我尝试了两者,并得到了相同的错误。
Check if root has rights to the IP address from your address - I am running this from the same computer and it has worked fine with localhost so I dont know why it wouldnt but how would I check this? 检查root是否具有从您的地址访问IP地址的权限-我正在同一台计算机上运行它,并且它在localhost上运行良好,所以我不知道为什么不会,但是我将如何检查呢?
Make sure you are providing password - I did when I tried to connect to the database and got this error. 确保您提供的密码-我尝试连接数据库时遇到了这个错误。
Could someone please help me, I have been searching for hours and cant find how to fix this. 有人可以帮我吗,我已经搜索了几个小时,无法找到解决方法。
You need to grant access to the account root@%
. 您需要授予对帐户root@%
访问权限。
root@localhost
and root@%
are two different accounts. root@localhost
和root@%
是两个不同的帐户。 When you're using localhost
as the hostname, and specify user name root
, you use root@localhost
. 当您使用localhost
作为主机名并指定用户名root
,请使用root@localhost
。
When connecting using an external IP, you need to grant database access for root@%
. 使用外部IP连接时,需要授予root@%
数据库访问权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.