通过服务器连接到 MySQL 数据库 [英] Connecting to MySQL Database over server

查看:49
本文介绍了通过服务器连接到 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用网络等方面,我是一个初学者,所以先向你道歉.不久前,我在我的机器上本地设置了一个 mySQL 数据库,并构建了许多使用它的简单程序.(又名 root:localhost 之类的东西).

I'm quite a beginner when it comes to working with networks and the like, so apologizes up front. A while back I set up a mySQL database locally on my machine, and have built a number of simple programs that work with it. (aka root:localhost sort of thing).

这很好,但我现在希望让我工作的其他同事从他们的机器上访问数据库,但我不知道怎么做.

This has been great, but I'm now hoping to allow other colleagues at my work to access the database from their machines, but I have no idea how.

可能会有一些网络保护问题(防火墙等),因此可能需要考虑...(虽然我有 IT 的帮助,但 IT 或我自己都不知道连接"需要什么到数据库).

Likely there will be some network protection issues (firewalls etc), so that may need to be taken into account... (although I have IT's help on this, neither IT or myself really know what is required to 'connect' to the database).

例如,它只是我需要的 IP 吗?我必须更改数据库的设置吗?我知道 localhost 不能在我同事的计算机上工作,出于显而易见的原因,我不知道其他人可以访问它的位置.

For example, is it just an IP I need? Do I have to change the setup of my database? I understand that localhost would not work from my colleagues computer's, for obvious reasons, I have no idea what would go in its place for others to access it.

我也不介意让我的机器作为专用数据库机器运行...我无法在我的机器之外的专用服务器或类似的东西上运行它.

I also do not mind having my machine run as the dedicated database machine... I would not be able to run it off a dedicated server or anything like that, beyond my machine.

任何帮助将不胜感激!谢谢.

Any help would be much appreciated! Thanks.

推荐答案

首先,你的同事需要的是:

First of all, what your colleagues need are:

  • MySQL服务器所在的IP地址跑步.
  • 远程连接的用户名和密码
  • 在网络上打开端口 3306
  • 一个 MySQL 客户端(mysql 工作台、mysql 查询浏览器、toad、heidi 或只是命令行工具).

当您在 MySQL 中创建用户时,必须是这样的:

When you create user in MySQL the have to be something like this:

'root'@'localhost'

这意味着,如果您使用 root 用户从 localhost 连接,该用户将工作.因此,您可以创建允许从任何地方连接的用户:

That means, the user will work if you connect from localhost with the user root. So you can create user allowed to connect from anywhere:

'juanperez'@'%'

最后你要小心你授予他们什么特权.不要忘记在 MySQL 的选项文件中注释绑定地址"的行(此选项可防止远程连接).

And finally you have be careful about what privileges are you granting to them. Do not forget to comment a line in the options file of the MySQL that says "bind-address" (this options prevents remote connection).

这篇关于通过服务器连接到 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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