Unable to connect to GCP cloud SQL private instance - mysql

We have create private cloud instance but I am unable to connect to it using MYSQL workbench, php or a ODBC client.
From the same compute instance I can connect using mysql -h IP -u user -p *****. With GCP services I usually find gotcha in some document and I have tried digging everything possible. Here below error from a ODBC client:
BIP2393E: Database error: ODBC return code '-1' from data source ''DEVA'' using ODBC driver manager ''/opt/iib-10.0.0.20/ie02/lib/libodbcinterface.so''.
The integration node received an error when processing a database operation. The ODBC return code was '-1'. See the following messages for information obtained from the database about this error.
Use the following messages to determine the cause of the error. Typical problems are an incorrect data source, or table names. Correct either the database or the integration node configuration. Use the mqsicvp command to test connectivity to this database.
BIP2322E: Database error: SQL State ''HY000''; Native Error Code '2003'; Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Can't connect to MySQL server on '1x.1x.1x.1x' (110)''.
The error has the following diagnostic information: SQL State ''HY000'' SQL Native Error Code '2003' SQL Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Can't connect to MySQL server on 'x.x.x.x' (110)''
This message may be accompanied by other messages describing the effect on the integration node itself. Use the reason identified in this message with the accompanying messages to determine the cause of the error. Use the mqsicvp command to test connectivity to this database.
If I try and use a local proxy I get below:
BIP8299I: User 'user' from security resource name 'BIGDEVA' will be used for the connection to datasource 'DEVA'.
BIP8290I: Verification passed for the ODBC environment.
2020/07/16 20:29:41 New connection for "sql-instance"
2020/07/16 20:31:49 couldn't connect to "sql-instance": dial tcp x.x.x.x:3307: connect: connection timed out
BIP2393E: Database error: ODBC return code '-1' from data source ''DEVA'' using ODBC driver manager ''/opt/iib-10.0.0.20/ie02/lib/libodbcinterface.so''.
The integration node received an error when processing a database operation. The ODBC return code was '-1'. See the following messages for information obtained from the database about this error.
Use the following messages to determine the cause of the error. Typical problems are an incorrect data source, or table names. Correct either the database or the integration node configuration. Use the mqsicvp command to test connectivity to this database.
BIP2322E: Database error: SQL State ''08S01''; Native Error Code '2013'; Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0''.
The error has the following diagnostic information: SQL State ''08S01'' SQL Native Error Code '2013' SQL Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0''
This message may be accompanied by other messages describing the effect on the integration node itself. Use the reason identified in this message with the accompanying messages to determine the cause of the error. Use the mqsicvp command to test connectivity to this database.

Private cloud instance I meant that the network it sits in has no internet access, I guess it was not needed. Subnet A holds the client VM and Subnet B holds the DB instance and they have SA account based firewall rules. Though we found the issue as the firewall was open on service accounts on the VM so using a mysql client was working but apparently GKE POD subnet need it's own firewall rules and it doesn't inherit VM SA account/tag rules whereas a standalone docker container on it's own does.

Related

How do I connect to my RDS MySQL instance programmatically?

Problem
I launched a MySQL RDS instance and was able to successfully connect to it using MySQL Workbench. However, I am still not able to connect to it from my local workstation using the following URI:
'mysql+pymysql://user:password#db_identifier.XXXXXXXXXX.us-east-1.rds.amazonaws.com:3306/db_name'
or the same URI without the port:
'mysql+pymysql://user:password#db_identifier.XXXXXXXXXX.us-east-1.rds.amazonaws.com/db_name'
The error that I receive when I specify this as my database URI and execute a db.create_all() command is:
sqlalchemy.exc.OperationalError:
(pymysql.err.OperationalError)
(2003, "Can't connect to MySQL server on 'db_identifier.XXXXXXXXXX.us-east-1.rds.amazonaws.com'
([WinError 10060] A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed because
connected host has failed to respond)")
Question
What can I do to connect using pymysql? And why would it connect with MySQL Workbench and not through this URI?
Context
I am following the tutorial here. This uses SQLAlchemy to execute the SQL statements in Python.
The RDS instance (and its associated subnet/VPC) have the following:
a security group open on port 3306
NACL rules that allow incoming and outgoing traffic
Public Accessibility set to "Yes"
Check my answer on this post, it could be something about the "Public accesibility" option in your rds "Connectivity and Security" section as described here;
https://stackoverflow.com/a/63514997/2934184

Cannot connect to AWS RDS instance that is not in VPC

In our company we use few AWS RDS MySQL instances while few of those aren't in any VPC (we have created those 3 years ago).
I need to connect to such an instance using Microsoft SQL Server Management Studio but when I'm trying to do so I'm getting following error after few seconds:
TITLE: Connect to Server
Cannot connect to host_path.amazonaws.com.
------------------------------ ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
was not accessible. Verify that the instance name is correct and that
SQL Server is configured to allow remote connections. (provider: Named
Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(Microsoft SQL Server, Error: 53)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=53&LinkId=20476
The network path was not found
If I add the port after the host path like described there
I'm getting different error:
TITLE: Connect to Server
Cannot connect to host_path.amazonaws.com,3306.
------------------------------ ADDITIONAL INFORMATION:
Internal connection fatal error. Error state: 18 (System.Data)
The thing is that the link above they are talking about DB instance that is within VPC but our isn't.
Did anyone of you stuck with similar issue earlier and maybe know how to resolve that or at least can point me out to the correct way?
I've Googled a lot regarding this issue but every forum or FAQ says about DB instance within VPC which isn't my case.
In screenshot below
you can see the connection window within the program, all sensitive data has been painted over.
Thank you in advance.
Pretty sure you cant directly connect from SSMS to a MySQL database. I think you can setup a "Linked Server" (basically an ODBC driver/datasource, then connect to your localhost, which in turn talks to MySQL).
See: https://learn.microsoft.com/en-us/sql/relational-databases/linked-servers/create-linked-servers-sql-server-database-engine?view=sql-server-2017
I'm assuming your requirement for SSMS is that you plan to reference data from both SQL Server and MySQL? If so, it should work, but its performance wont be great.

AWS Database Migration Services endpoint errors

I'm trying to setup a source MSSQL endpoint and a target MYSQL endpoint, each exist in the same vpc as the replication instance setup but I receive
Operation:testEndpointDetails:[errType=ERROR_RESPONSE, status=122502, errMessage=Failed to connect [122502] ODBC general error., errDetails= RetCode: SQL_ERROR SqlState: HY000 NativeError: 15 Message: [unixODBC][Simba][SqlServerODBC] (15) Failed to connect to the SQL Server instance: [HY000]: Connection broken [122502] ODBC general error.]
for the MSSQL source test.
and
Operation:testEndpointDetails:[errType=ERROR_RESPONSE, status=122502, errMessage=Cannot connect to ODBC provider [122502] ODBC general error., errDetails= RetCode: SQL_ERROR SqlState: HY000 NativeError: 2003 Message: [unixODBC][MySQL][ODBC 5.3(w) Driver]Can't connect to MySQL server on 'mysql_endpoint' (110) [122502] ODBC general error.]
for the MYSQL target test.
I've reentered in the credentials numerous times setting the server name for both the source and target to the subsequent RDS endpoints of each instance as well as their corresponding login credentials, ports etc.
The first thing to check is your security groups to ensure that both systems can talk to each other. It's not enough for them to reside in the same VPC. If you have ec2 instances that use the source, you could possibly use this as the security group.
The above suggestion from John Paul Hayes was correct, security group on both RDS instances was changed from a custom one setup to the default AWS one.

“The server was not found or was not accessible” Error for SQL Server 2008

Error message is like this:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 51 - An instance name was not specified while connecting to a Local Database Runtime. Specify an instance name in the format (localdb)\instance_name.)
And my scenario: IIS and SQL Server 2008 are on the same test workstation, whose firewall is not enabled at all. I don't see any SQL Server log so I can't find any other useful information than the error message above.
I installed SQL Server as default instance (MSSQLSERVER)
My connection string is like this (I am using SQL Server account for authentication):
Server=(localdb); Database=MY_DB_NAME; User ID=MY_USER_ID; Password=MY_PASSWORD
I already verified this user has access to the target database (as owner)
I have gone through some articles on how to track down this problem: I set "allow remote connection" even though IIS and SQL Server are on the same machine. I don't need to set-up firewall.
If you have a standard, unnamed instance, you should use . or (local) (but not (localdb) !) as your server name
Try to use this connection string:
Server=(local); Database=MY_DB_NAME; User ID=MY_USER_ID; Password=MY_PASSWORD

Issue with Azure Emulator and SQLLOCALDB

When in try to start azure storage emulator i get the following error.
Caught exception while probing for SQL endpoint. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Number of Sql Errors Reported: 1 Sql Error: System.Data.SqlClient.SqlError: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
All the Components have been correctly installed .
Kindly Help
Thanx
I managed to fix it by deleting and creating my LocalDb instance. In my case it happened because I installed Azure SDK 2.2 over version 2.1.
The step-by-step to fix it:
Run sqllocaldb i to get your instance name:
C:\Users\myUser>sqllocaldb i
v11.0
Stop LocalDB instance:
C:\Users\myUser>sqllocaldb p v11.0
LocalDB instance "v11.0" stopped.
Delete your LocalDB instance:
C:\Users\myUser>sqllocaldb d v11.0
LocalDB instance "v11.0" deleted.
Create your LocalDB instance with the same name:
C:\Users\myUser>sqllocaldb c v11.0
LocalDB instance "v11.0" created with version 11.0.
Delete database files to allow emulator to recreate db files
C:\Users\myUser\DevelopmentStorageDb22.mdf
C:\Users\myUser\DevelopmentStorageDb22_log.ldf
That should fix your issues.
It looks like your windows account under which you logged in is not sysadmin in sqlexpress instance. Normally emulator uses database within sqlexpress with windows authentication.
The first time you run the Windows Azure storage emulator, an initialization process runs to configure the environment. By default, the initialization process creates a database in SQL Express LocalDB. So, please make sure that your SQLExpress service is running and your login have sufficient rights to use the database within SQLExpress.
If you want to make use of a local instance of an SQL Server to be used by Storage Emulator follow steps listed at http://msdn.microsoft.com/en-us/library/windowsazure/gg433134.aspx.
HTH
Sameer
What i am suspecting is that your LocalDB configuration with emulator is somehow corrupted or misconfigured.
Please follow the blog below to see if you can verify LocalDB instance is ready/working and it is used by Emulator:
http://blogs.msdn.com/b/avkashchauhan/archive/2012/07/10/windows-azure-sdk-1-7-storage-emulator-and-localdb.aspx
If you still have problem the easiest method would be to uninstall SDK 1.7 completely and re-install which will fix any issue with your configuration rather the finding the problem and try to fix which could take longer.
I was getting a similar message:
Probing SQL Instance: 'localhost\SQLExpress'.
Caught exception while probing for SQL endpoint. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Number of SqlErrors Reported: 1
SqlError: System.Data.SqlClient.SqlError: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
No available SQL Instance was found.
One or more initialization actions have failed. Resolve these errors before attempting to run the storage emulator again.
Error: No available SQL Instance was found.
For me the problem was due to the fact that I was not running with administrator privileges.
Might be a little late to the party here, but I've seen this happen if you clear out or remove items in your "C:\Users[USER_NAME]\AppData\Local\Temp" folder.
At the time of writing this, Azurite is the replacement for "azure storage emulator". In my case, I was able to simply follow the steps here https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=npm#install-azurite to get it installed, and you should be good to go after that.