1

I located the /etc/mysql/my.cnf file

I changed the bind-address

first to 0.0.0.0 I received a '111 Connection refused'

then I changed it to the instance I am trying to connect to It still says '111 Connection refused'

the firewall rule allows connection on port 3306 using internal ip so I dont know the problem. Thanks

Micheal Powers
  • 41
  • 1
  • 2
  • 8

2 Answers2

0

It seems that you have already taken the necessary steps to connect to MySQL server from GCE your instance. Based on the Stackoverflow case here the recommendation to resolve this problem is to comment this line below (add # at the beginning of the line) in your my.cnf file: skip-networking

Once done you need to restart MySQL service sudo service mysql restart On the GCP side, if you have allowed the IP ranges you want to use with the specified port(3306), it should work fine. You can also use “nmap” command to verify if port 3306 is open on your GCE instance with MySQL installed.

GCP provides CloudSQL which is a managed MySQL instance. You can access CloudSQL from your GCE VM using private address. This feature reached beta recently. This link provides detailed information about using private IP to connect to your Cloud SQL instances. Before configuring a Cloud SQL instance to use private IP, you need some steps to be taken. This document provides step by step instructions for configuring an instance to use private IP.

hidefromkgb
  • 5,834
  • 1
  • 13
  • 44
shamma
  • 151
  • 9
  • This is not the correct answer it doesn't solve the issues. If you read the question I am not connection to Cloud SQL I am connecting between mysql server's in different google compute instances in the same VPC using internal ip – Micheal Powers Oct 03 '18 at 16:23
  • In the first part of my answer I gave you some steps to establish connection between MySQL server from compute instance. In your my.cnf file: skip-networking (add # before the line) Keep the bind-address = 0.0.0.0 or you can also comment that line too. Once done you need to restart MySQL service sudo service mysql restart You can also use “nmap” command to verify if port 3306 is open on your GCE instance with MySQL installed. Have you already tried those steps? – shamma Oct 03 '18 at 20:18
  • Yes as it says on my question bro. – Micheal Powers Oct 03 '18 at 22:23
0

You can use 'netstat -tunlp | grep 3306' command to verify that the MYSQL process is running on port 3306.
This error can also occur when mysql user account does not accept connections from any IP addresses. It may still use localhost parameter to connect to the server. I would recommend adding a user with remote access or granting existing user access to remote sources. You can see this: link for the similar issue and follow the steps recommended there to resolve.

DuDa
  • 3,718
  • 4
  • 16
  • 36
shamma
  • 151
  • 9