remotly连接到MySQL [英] connect remotly to mysql

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

问题描述

我安装在同一个电脑 VM Windows 7的,我有下面的代码形式:

i setup a windows 7 on vm on the same pc, i have a form with the following code:

MySqlConnection connection = new MySqlConnection("SERVER = 127.0.0.1; DATABASE = my_test; UID = root; PASSWORD = 'XXXX';");

private void Form1_Load(object sender, EventArgs e)
{
    MySqlCommand cmd = new MySqlCommand("SELECT * FROM info", connection);
    connection.Open();
    MySqlDataReader reader = cmd.ExecuteReader();
    if (reader.HasRows)
    {
        while (reader.Read())
        {
            MessageBox.Show(reader[1].ToString());
        }
    }
    reader.Close();
    connection.Close();
}

这是我的 PC 我成功地连接到数据库,现在我复制我的应用程序粘贴到虚拟机,我收到了 JIT 的错误,我没有对 VM (没有 appache 没有的mysql 只是.NET框架4.0)
I的确让我的根用户一样,远程启用:

on my pc i successfully connect to the db, now i copy and paste my app to the vm and i get a jit error i don't have any thing on the vm (no appache no mysql nothing but net framework 4.0) i did make my root user remote enabled like that:

GRANT ALL ON *以'%'@'%'WITH GRANT OPTION; <。 / code>

GRANT ALL ON *.* to '%'@'%' WITH GRANT OPTION;

现在我仍然坚持,所以如何连接到与分贝我的 IP 等等在 VM 能找到它,我需要在 VM

now i still stuck, so how to connect to the db with my ip so the vm can find it, and do i need to setup anything in the vm?

注:我可以用另一种 PC 如果问题的VirtualBox ,但我怀疑它有什么做的的VirtualBox

Note: i can use another pc if the problem in the VirtualBox but i suspect that it has nothing to do with the VirtualBox.

我很困惑我做了这个形式

i am confused i made this form

和我将它移动到虚拟机,我只问:在文本框写什么

and i move it to the vm and i asking simply: what to write in that textbox?

推荐答案

当您连接到 127.0.0.1 ,您连接到当前系统中。无论是运行的系统:主要还是 VM 。您应该配置的的VirtualBox的网络设置 VM 可以连接到您的主系统。在这种情况下,你会从 VM 不是本地主机,而是你设置主操作系统 IP地址进行连接。

When you connect to 127.0.0.1, you connect to the current system. Regardless of what system is running: main or vm. You should configure network settings of the VirtualBox so that vm can connect to your main system. In this case you'll connect from vm not to localhost but to IP-address that you set to main OS.

或者你可以设置的MySQL VM 和移动数据库到的MySQL

Or you can setup MySQL to the vm and move your database to that MySQL.

修改

有关测试连接的MySQL 您可以使用远程登录 http://windows.microsoft.com/en-us/windows/telnet-faq #1TC =窗口 - 7 )。
首先,你应该知道的MySQL 端口。您可以从的MySQL 配置得到它,或者尝试从@Prageeth Roshane的回答端口。那么你应该尝试从的VirtualBox 连接到的MySQL 来瑶池端口。您可以使用或PROGRAMM或远程登录。如果你有连接的烦恼,尝试检查,在虚拟机和主操作系统防火墙没有阻止你PROGRAMM(或telnet)。

For testing connection to MySQL you can use telnet (http://windows.microsoft.com/en-us/windows/telnet-faq#1TC=windows-7). At first you should know the MySQL port. You can get it from MySQL config or try ports from @Prageeth Roshane' answer. Then you should try to connect from VirtualBox to MySQL to finded port. You can use or programm or telnet. If you'll have troubles with connections, try to check that the firewall in VM and in main OS is not blocked your programm (or telnet).

P.S。如果可以从另一台电脑连接到的MySQL ,但水湿从VM连接,那就麻烦是在虚拟机的网络设置。

P.S. If you can connect to MySQL from another PC, but cann't connect from VM, then trouble is in VM's network settings.

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

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