Trying to connect to SQL Server on gcp? - google-cloud-platform

I've created a new SQL Server instance and database on GCP. The "Overview" tab shows the following info:
Connect to this instance
Public IP address: 35.223.145.123
Instance connection name: my-quest-263123:us-central1:my-instance-1
The connections tab has "Public IP" checked. I was able to "Add Network" on this tab with my public ip address. An instruction next to the Network input says "Use CIDR notation." I wasn't able to figure out how to do this offhand but this input accepted my standard public IP address. SSL is not enabled/required for this connection.
I updated the password for the SQL Server user on the Users tab and attempted to login to this SS instance via SSMS with:
Server name = my-quest-263123:us-central1:my-instance-1
Authentication = "SQL Server Authentication"
Login = sqlserver
Password = (sqlserver password)
However, I wasn't able to connect to the instance using this approach. I also created a new User for my GCP SQL instance but I wasn't able to connect to the instance with this new user either. Any idea what I might be missing here?

Any idea what I might be missing here?
Please bear in mind that Cloud SQL with SQL server is still in beta and it may cause unexpected behaviors. If you have the option, you could always change to use MySQL or PostgreSQL.
As for your actual set up, I highly recommend you to follow the next tutorials since you will find out how to connect to your SQL server instance with SSMS and with the command-line through the Cloud Shell:
If you would like to do local testing, you could use the Cloud SQL proxy and refer to this documentation.
If you would like to use SSMS you can always follow the next documentation.
Following either of those tutorials you should be able to connect successfully to your SQL server instance.
I hope it helps.

For connecting SSMS to a Cloud SQL for SQL Server instance, the recommended approach is to use the Cloud SQL Proxy, which gives you a secure SSL connection to the database. Here's a blog post that covers how to do that, let me know if you have any questions: Managing SQL Server instances in Cloud SQL.

Related

Connecting to Cloud SQL from a host without a fixed IP

I have a server running at home but I haven't a fixed ip address. So, I use DDNS to update my domains DNS when IP changed, and it is working fine. My problem comes trying to access a MySQL instance, because currently it is using a VPC, so I need to update manually adding new IP as Authorized Network. I wonder if it is possible to do that with a API REST call, in that way I can add a crontab in my server to check changes each n minutes and update Authorized Networks.
I read Google documentation, but in my understanding (I am not an english speaker) it is possible just from an authorized network. Somebody can give me a clue?.
Thanks in advance.
Take a look at installing and using Cloud SQL Auth Proxy on your local server. This will remove the need to keep updating Authorized Networks when your IP changes.
I wonder if it is possible to do that with a API REST call, in that
way I can add a crontab in my server to check changes each n minutes
and update Authorized Networks.
Google Cloud provides the Cloud SQL Admin API. To modify the authorized networks, use the instances.patch API.
Google Cloud SQL Method: instances.patch
Modify this data structure to change the authorized networks:
Google Cloud SQL IP Configuration
You might find it easier to use the CLI to modify the authorized networks:
gcloud sql instances patch <INSTANCENAME> --authorized-networks=x.x.x.x/32
gcloud sql instances patch
I do not recommend constantly updating the authorized networks when not required. Use an external service to fetch your public IP and compare with the last saved value. Only update Cloud SQL if your public IP address changed.
Common public services to determine your public IP address. Note you should randomly select one as these services can rate limit you. Some of the endpoints require query parameters to only return your IP address and not a web page. Consult their documentation.
https://checkip.amazonaws.com/
https://ifconfig.me/
https://icanhazip.com/
https://ipecho.net/plain
https://api.ipify.org
https://ipinfo.io/ip
Note: I recommend that you use the Google Cloud SQL Auth Proxy. This provides several benefits including network traffic encryption. The auth proxy does not require that you whitelist your network.
Refer to my other answer for more details

How to connect to a GCP (Google Cloud Platform) Cloud SQL instance from an IPV6 address?

I am trying to reach our Postgres SQL server running as a GCP Cloud SQL instance from the PgAdmin 4 tool on desktop. For that you have to whitelist your IP address. Until this point it was working fine, the whole team used IPV4 addresses, but I moved to a new country where my new ISP assigned an IPV6 address to me, and it seems like GCP doesn't allow IPV6 addesses to be whitelisted, thus you can't use them to connect.
Here's a picture of the Connections/Allowed Networks tab:
Is there any kind of solution to this?
Or do they expect me to only have ISPs who assign IPV4 addesses to me?
Thank you.
Alternatively, you could just use the Cloud SQL Auth Proxy directly. You'll have to run an instance of it on your local machine and then PgAdmin can connect to the proxy on localhost.
Yes, there is a workaround for this but not using the UI, instead you need to use the Cloud SDK.
This has recently been added to cloud SDK beta. So as you can see in the documentation for gcloud sql connect:
If you're connecting from an IPv6 address, or are constrained by certain organization policies (restrictPublicIP, restrictAuthorizedNetworks), consider running the beta version of this command to avoid error by connecting through the Cloud SQL proxy: gcloud beta sql connect.
I couldn't find any Feature Requests for this being implemented into the UI at the moment, so if you'd like to have this changed I would suggest you to open one in Google's Issue Tracker system.

In DataPrep, How to create connection with instance of sql without public ip on google cloud platform?

In Dataprep, when creating the connection there is the 'Test Connection' button, after filling in all the connection data, with the private ip, port, username and password, I click on the test button and I get the error [Unable to connect to host] SocketTimeoutException: Connection timed out.
I correctly configured the subnetwork settings in the 'execution settings' preferences, as indicated in this link
https://community.trifacta.com/s/article/Configure-Dataprep-to-run-Dataflow-jobs-in-a-custom-VPC
My SQL instance on google cloud platform has no public ip, only private ip, I'm not getting dataprep to connect to the database, how should I proceed, is there any additional configuration for it to work?
I'm also not able to find material and documentation about this, if you can help me, I'll be grateful.
I found such a description in the official document.
NOTE: Relational datasources must be available on a public IP address that is accessible from the deployment of Dataprep by Trifacta Premium.
As others have answered, you cannot.

Connect to RDS eb2 by tableplus?

I have table plus app and I create eb then deploy my project then connect to database and all thing is good and cool!
I need to connect to database(MYSQL) to import some data to the AWS database so I do these steps:
open new workspace in table plus
take endpoint and username of database and the password and the name of database like so:
press Test button and after wait some times I got this error:
I change the port to also 5432 and got same first error
I change the port to 3306 and got this error:
where is the problem ?
Ok the way i did it was by following this video:
https://www.youtube.com/watch?v=saX75fTwh0M&ab_channel=AdobeinaMinute
In short you need to get the details of your instance and set up an ssh connection to it using its hostname (ie that of the instance not the db), your ec2 username (usually ec2-user) and your pem file. Then you get the connection details for the db and enter them. See the screenshot.
I think that your problem is that the configuration you created is set to a Redshift connection. It expects some network communications that are different from a MySQL connection.
Can you try to create a MySQL connection instead?
I had the same issue but my problem was with the security rules in aws. perhaps, this may help.
Navigate to the console
edit inbound rules of your rds instance
add a new security rule
where: type: 'all traffic', source: anywhere
This video gives a google explanation: aws rds setup

Google Cloud SQL migration from the first to second generation

Google Cloud SQL: after an upgrade SQL from the first generation to second MySQL workbench can’t connect my instance in Cloud. Why?
Maybe you need to do instance 5.7 ?
Google application Engine: after upgrade SQL from the first generation to second MySQL opening a new WEB application and connect to my project in Cloud, it can’t see my instance. Why?
Any of these three configurations might eventually prevent the connection from GAE:
a) If you haven't assigned any public IP address to the instance;
the only option to connect would be: Configuring Serverless VPC Access.
b) Confirm and complete the upgrade reads:
If your applications are connecting using the First Generation instance connection name:
<project_id>:<instance_id>
update them to use the Second Generation instance connection name:
<project_id>:<region>:<instance_id>
c) Another possible culprit would be the service-account used - and it's assigned roles:
App Engine uses a service account to authorize your connections to Cloud SQL. This service account must have the correct IAM permissions to successfully connect. Unless otherwise configured, the default service account is in the format service-PROJECT_NUMBER#gae-api-prod.google.com.iam.gserviceaccount.com.
Authorization with authorized networks is usually not required when connecting from GAE.