Import Data into Cloud SQL Using Cloud SQL Client Connection Ended - mysql

I am trying to run a SQL script from MySQL workbench, and have it import data to Cloud SQL using Cloud SQL Client proxy. This SQL script is about 10 GB. I have tried this a few times, and it takes too long, and says the certification of the connection will expire soon. Soon after that, the so the connection ends, and I see an error on workbench saying lost connection to MySQL server.
Are there any suggestions on what I should do / do different?
I am not wanting to use Cloud SQL Buckets to import data, and hence am going the route of Cloud SQL Client.

Your connection ended error can be due to many different reasons. One being your script is too large and is causing the connection to timeout. I would suggest splitting your script and importing them separately.
It is possible that the “certification of the connection will expire soon” error can be resolved by rotating your server certificates. You can find how to do that here: https://cloud.google.com/sql/docs/mysql/manage-ssl-instance#manage-server-certs

Related

How to fix Named Pipes Provider, error: 40 - Could not open a connection to SQL Server?

I'm having trouble connecting or logging in to my SQL Server database. I had a previous working instance before, but I forgot the password and decided to just reinstall the whole thing since I don't have any data to lose. I realized that was a bad idea but now, each time I attempt to log in to my SQL Server, I get the following error message:
I tried to search for an answer, but it seems nothing is working. Here is what I tried so far:
Enabling the Named Pipes from the SQL Server Configuration Manager under the SQL Server Network Configuration tree item
I tried restarting the SQL Server item from the list of services in the Services application
I tried restarting everything in the SQL Server Configuration Manager that is related to my database or at least have my instance's name on it
There are other things that I tried which I fail to remember. Any help would be much appreciated.

How to close connection to a remote MySQL database?

I was testing my SpringBoot app which connects to a remote SQL database. I was also using MySQL workbench to view the tables. Then when I tried to run my app, it gave an error message as follows:
Data source rejected establishment of connection, message from server: "Too many connections"
I have tried restarting my PC but it still gives the same error. How can I solve it? I believe the previous connection was not properly closed. What can I do now?
The connections are automatically closed (or return to the connection pool) if you are using Spring Data Repository or JdbcTemplate. Your application may really need too many connections compared to your database limit, in that case you should check your database configuration. You can also check your connection properties in application.properties (pool size, idle time, timeout). Please add more details like code or configuration.

Google cloud_sql_proxy unable to connect to instance, stream error, protocol_error

I've been successfully using the Google cloud_sql_proxy on multiple Compute Engine instances for some time, until today, one instance at a time, the proxy started to show the following error pattern:
2017/05/30 13:28:07 New connection for "project-id-1234:us-central1:sql_instance"
2017/05/30 13:28:07 couldn't connect to "project-id-1234:us-central1:sql_instance": Post https://www.googleapis.com/sql/v1beta4/projects/project-id-1234/instances/sql_instance/createEphemeral?alt=json: stream error: stream ID 1; PROTOCOL_ERROR
2017/05/30 13:28:41 New connection for "project-id-1234:us-central1:sql_instance"
2017/05/30 13:28:41 Thottling refreshCfg(project-id-1234:us-central1:sql_instance): it was only called 33.490705951s ago
2017/05/30 13:28:41 couldn't connect to "project-id-1234:us-central1:sql_instance": Post https://www.googleapis.com/sql/v1beta4/projects/project-id-1234/instances/sql_instance/createEphemeral?alt=json: stream error: stream ID 1; PROTOCOL_ERROR
When trying to connect directly to MySQL (while using the proxy) I get error 2013 (HY000):
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"
What I've tried
Restarting the cloud_sql_proxy yielded a temporary fix until finally both my Compute Engine instances are unable to connect to my Cloud SQL instance and the proxies show only this result.
Restarting the Cloud SQL instance and both Compute Engine instances.
Eliminating the proxy: I added the appropriate networks to my SQL instance's Authorized Networks, and updated all applications to use the public IP. This restored functionality to my production apps, but now I'm using a public connection instead of local/proxy.
Some research
I came across a similar issue relating to Google Cloud SQL that yielded the same MySQL error above, but it appears to have only affected connecting to Cloud SQL from external, non GCE/GKE networks.
A few others have reported the same issue also started for them this morning on the Google Cloud SQL Discuss group.
My team started seeing the same issue appear today, with GKE managed servers. Same as you saw: restarts of servers and DB did nothing.
We tried doing an update of the version of Google Cloud Proxy we were using from v1.05 to v1.09 and the problem went away (for now).
I know that's not much of an explanation but give it a try to see if that helps you.

FireDAC Lost connection to MySQL server during query

I have two FireDAC connections on my application, one is intended to be used on a MySQL Server that is on LAN and store private data of the my shop (like sales, products, etc), and the another one is connected to a remote (internet) MySQL Server, and it randomly give me a exception
First chance exception at $745AA882. Exception class
EMySQLNativeException with message '[FireDAC][Phys][MySQL] Lost
connection to MySQL server during query'.
Is this a issue on FireDAC, my code or the remote MySQL Server?
Using NAVICAT software I have no problem.
This error usually occurs because the Internet Connectivity is not stable and connection closed during exchanging data
Sometimes you can solve this issue with increasing the connection Time-Out (and ReadTimeOut )
Sometimes this error occurs because you are trying to send or receive large amount of data like Blob fields and you should increase the max_allowed_packet variable of MySQL Server to solve the problem
The next suggestion for solving this problem is avoiding dns lookup by adding skip-name-resolve to the settings of your MySQL Server
The Main reasons of this problem is connection stability and MySQL Server Settings
If you have access to MySQL server and can change the settings, this link may be useful :
http://www.monitis.com/blog/101-tips-to-mysql-tuning-and-optimization/
You can find many articles about increasing performance of MySQL Server

A transport-level error has occurred... (Existing connection closed by the server) Sql Server 2008

I have a web application which is currently running on Windows XP operating system with SQL Server 2005 database and IIS 6.0.
Now, we are trying to upgrade it to IIS 7.0 on Windows Server 2008 and SQL server 2008 database.
When I run the application then it is throwing "A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)" randomly at different database calls.
I have verified using "sp_who" that only one connection which I am using is opened.
Can anyone tell me, what could be the cause of this issue?
This blog post by Michael Aspengren explains the error message "A transport-level error has occurred when sending the request to the server."
Maybe the database is set to auto-close? This used to be the default for databases created on the older MSDE/Express edition.
ALTER DATABASE YourDatabaseName SET AUTO_CLOSE OFF;
More:
The SQL Server 2005 Express Edition Overview states:
Features like Auto-Close and the ability to copy databases as files are enabled by default in SQL Server Express ...
I can't remember which service pack changed the default, but the New Database UI in the SP3 version of Management Studio Express defaults the Auto Close setting to false.
This is an error that occurrs when connecting to database due to a lower layer network-related error that you cannot handle from Sql Server.
It would be great that the API used to conenct handled this error but AFAIK it is not. The only way to solve this is to retry connecting to the database when this error occurrs.
You should try to reconnect at least a couple of times more to get sure that the error is not persistent and if it is the case then throw the exception. My experience tells me that trying to reconnect, the 99.9% of times you will succed.
Often, it's the database being offline/closed or the SQL Instance being restarted/offline
In my case. We have DELL R720, NICs are on board and PCI Broadcom NetXtreme Gigabit Ethernet cards. We run into two issues.
Network speed is very slow for HyperV VMs. The solution is to disable the "Virtual Machine queues" of the HyperV host Broadcom nic property windows. It is in the Advanced tab.
SQL client having this transport level issue. It only happened once in every 10-15 min. At the same time the RDP service kick out client from time to time also. The solution is to disable the "Large Send Offload V2" of the HyperV host Broadcom nic property windows. It is in the Advanced tab.
Check if you have MultipleActiveResultSets=true; set in your connection string.
Transport level errors are often linked to the connection to sql server being broken ... usually network.
Timeout Expired is usually thrown when a sql query takes too long to run. Is this the scenario in your case? Like stored proc taking too much time to execute or are there are batch jobs that are executed?
Use clearpool(urSQLconnection), along with dispose. This will clear the dirty connection. and you can open new connection.
Got this trying to execute commands from multiple threads on one connection object in .net, that was a stupid mistake. Locking it or using a separate connection per thread fixes that.
In my case it was McAffee that was pre-installed. Can tell if it was conflict with other solutions or not. The connection was on VPN, on WiFI. Maybe this will help someone in future.