简体   繁体   English

如何在Azure中连接到在Linux虚拟机上运行的mysql服务器

[英]how to connect to a mysql server running on a linux virtual machine in azure

I searched a lot but not able to solve that problem. 我进行了很多搜索,但无法解决该问题。 i am able to access MySQL server running on different windows machine. 我能够访问在不同Windows计算机上运行的MySQL服务器。 steps i have taken are 我采取的步骤是

  1. changing my.ini file bind address to 0.0.0.0 将my.ini文件绑定地址更改为0.0.0.0
  2. creating user and granting permission by GRANT ALL PRIVILEGES ON DATABASE.* TO user@'%' IDENTIFIED BY 'password'; 通过授予GRANT ALL PRIVILEGES ON DATABASE.* TO user@'%' IDENTIFIED BY 'password';创建用户并授予许可GRANT ALL PRIVILEGES ON DATABASE.* TO user@'%' IDENTIFIED BY 'password';
  3. from command line to windows MySQL server mysql -h windows server ip -u user -p 从命令行到Windows MySQL服务器mysql -h windows server ip -u user -p

it works fine and from MySQL workbench i am able to connect for windows MySQL server from my machine. 它工作正常,并且可以从MySQL工作台从我的机器连接Windows MySQL服务器。 BUT when in Linux virtual machine i have done the same thing 但是在Linux虚拟机中我做过同样的事情

  1. changing my.cnf file and change bind address to 0.0.0.0. 更改my.cnf文件并将绑定地址更改为0.0.0.0。
  2. creating user and granting permission by GRANT ALL PRIVILEGES ON DATABASE.* TO user@'%' IDENTIFIED BY 'password'; 通过授予GRANT ALL PRIVILEGES ON DATABASE.* TO user@'%' IDENTIFIED BY 'password';创建用户并授予许可GRANT ALL PRIVILEGES ON DATABASE.* TO user@'%' IDENTIFIED BY 'password';
  3. From command line to LINUX MySQL server mysql -h linux server ip -u user -p 从命令行到LINUX MySQL服务器mysql -h linux server ip -u user -p

    but for that i am getting following error after giving password ERROR 2003 (HY000): Can't connect to MySQL server on 'linux server ip' (10060) also when connecting from c# by following connection string <add name="MySqlConnection" connectionString="Server=LINUX_VM_SERVER_IP;Database=database;Uid=user;Pwd=password" providerName="MySql.Data.MySqlClient" /> i am getting Error : Unable to find and specified mysql host 但是为此,我在输入密码错误2003(HY000)后收到以下错误:在通过以下连接字符串<add name="MySqlConnection" connectionString="Server=LINUX_VM_SERVER_IP;Database=database;Uid=user;Pwd=password" providerName="MySql.Data.MySqlClient" />从c#连接时,也无法连接到'linux服务器ip'(10060)上的MySQL服务器 <add name="MySqlConnection" connectionString="Server=LINUX_VM_SERVER_IP;Database=database;Uid=user;Pwd=password" providerName="MySql.Data.MySqlClient" />我遇到错误:无法找到并指定mysql主机

  4. i have checked in LINUX_VM that 0.0.0.0:3306 is in listening status. 我已经在LINUX_VM中检查到0.0.0.0:3306处于侦听状态。

  5. if i try to telnet LINUX_VM MYSQL Server service using />telnet LINUX_VM_IP 3306 i got the ERROR : Connecting To LINUX_VM_IP...Could not open connection to the host, on port 3306: 如果我尝试使用/>telnet LINUX_VM_IP 3306 telnet LINUX_VM MYSQL Server服务,则出现错误:连接到LINUX_VM_IP ...无法打开端口3306上的主机连接:

First, try to connect to the database on the VM hosting the database. 首先,尝试连接到托管数据库的VM上的数据库。 If the connection is successful, then the configuration of the database is correct. 如果连接成功,则数据库的配置正确。 Otherwise, please check the configuration of your database. 否则,请检查数据库的配置。

Second, if you are able to connect to database on the VM, then the most possible cause of this issue is firewall. 其次,如果您能够连接到VM上的数据库,则此问题的最可能原因是防火墙。 Please check if the local firewall (iptables) allows inbound connection on port 3306. For test purpose, you may disable the firewall temporarily. 请检查本地防火墙(iptables)是否允许端口3306上的入站连接。出于测试目的,您可以暂时禁用防火墙。 Also, please check if the NSG has been configured properly to allow the inbound traffic on port 3306. 另外,请检查NSG是否已正确配置为允许端口3306上的入站流量。

Besides, if the VNET has been associated with a NSG, then we need to allow the inbound traffic in the NSG too. 此外,如果VNET已与NSG关联,那么我们也需要允许NSG中的入站流量。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何连接到在虚拟机上运行的MySQL服务器 - How to connect to a MySQL server running on a Virtual Machine 无法使用我的本地笔记本电脑连接到在 Azure 上的 Linux (ubuntu 16.04) 虚拟机上运行的 MySQL - Can't connect to MySQL running on a Linux (ubuntu 16.04) virtual machine on Azure using my local laptop 通过虚拟机连接MYSQL - Connect To MYSQL Through Virtual Machine 如何从本地计算机MySQL工作台连接到Azure Ubuntu VM MySQL服务器? - How to connect to Azure Ubuntu VM MySQL server from local machine MySQL workbench? 如何从Linux机器连接到Windows上的远程MYSQL服务器? - How do I connect to a remote MYSQL server on Windows from a Linux Machine? 如何通过Windows机器连接Linux服务器中的mysql数据库 - how do i connect to mysql database in Linux server through windows machine 如何从虚拟机连接 C# 和 MySQL? - How can I connect C# with MySQL from Virtual Machine? 如何远程连接在基于Vagrant的Ubuntu 16.04虚拟服务器上运行的MySQL? - How to connect to MySQL, running on a Vagrant-based, Ubuntu 16.04 virtual server, remotely? 如何在 linux 服务器中将现有 MYSQL 与 XAMPP 连接 - How to connect existing MYSQL with an XAMPP in linux server 如何使用另一个虚拟机访问托管在虚拟机上的 MySQL 服务器? - How to access a MySQL server hosted on a Virtual Machine using another Virtual Machine?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM