Lost connection to MySQL server at 'waiting for initial communication packet' - mysql

I have seen many stack overflows questions and some blogs tried workarounds, but nothings helped - hence re-posting the question with more details.
I am seeing the weird behaviour with MySQL and Python application, details are as follows:
1) My application works perfectly fine with MySQL (tried and tested on many platforms) but on this particular machine it fails to connect to MySQL.
structure of application is :
Windows service -> parent process -> Mysql(child process)
and when application tries to connect to MySQL it get this error:
ERROR 2013 , Lost connection to MySQL server at 'waiting for initial communication packet' - system error 0
I tried:
- connect_timeout=300
- skip-name-resolve=0
- firewall is OFF
- use 17.0.0.1, localhost , IP of machine to connect to but it still fails with same error.
2) Now the weird thing is -
If I manually follow all the steps which application does, It works perfectly fine, details are follows:
a) Start MySQL with same command (which application uses) with administrator privileges
mysql --default-file = xxx --basedir =xxx
b) Connect with same credentials ( -u root -P 6075 -h 127.0.0.1) and
It works perfectly fine, I double checked all the steps which application does, there is no difference between manually steps and application code.
AM I missing something here ? Any suggestions ?
MySQL version : 5.5.35
Python : 2.7
Base OS : Windows 2012 R2
Thanks in advance..

Found a reason - answering my question:
When I used to run MySQL from my application - it was running under system user privileges - so it used to pick "C:\WINDOWS\TEMP" as a temp directory- this directory was messed up - has lot of unnecessary files .. and MySQL was stuck while processing files under this directory...
But when I ran it manually under My administrator account it was using his temp directory... C:\Users\USER_NAME\AppData\Local\Temp and everything was working like magic...
To fix this permanently I changed tmp directory through MySQL conf file and now My Application runs like the Wind.... :)
[mysqld]
tmpdir = 'PATH_TO_THE_DIRECTORY'

I was getting this same error trying to set up a SQL Server Linked Server
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "DBLINKED".
OLE DB provider "MSDASQL" for linked server "DBLINKED" returned message "[MySQL][ODBC 8.0(w) Driver]Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060". (Microsoft SQL Server, Error: 7303)
You mentioned it in your initial question - the Connection Timeout was the issue for me.
The default is 0 - raised it to 300. I thought default of 0 would mean no timeout, but it's obviously something reasonably short, and I was trying to connect to a remote database on a slow internet connection. A lot of other question and answers out there relate to connecting within the same machine, so this error isn't reported much.

Related

Failed to connect to database: Error: Can't connect to MySQL server on 'xxxxxx.rds.amazonaws.com' (111)

I am trying to run this command locuscompare(in_fn1 = gwas_fn, in_fn2 = eqtl_fn, title1 = 'CAD GWAS', title2 = 'Coronary Artery eQTL') within R in ubuntu behind a corporate proxy
but having the following persistent issue for three days.
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'locuscompare-us-west-2a.xxxxxx.us-west-2.rds.amazonaws.com' (111)
Warning message:
In rm(config) : object 'config' not found
I have already tried the solutions mentioned in stack overflow, such as installing MySQL, assigning users' privilege, editing bind-address in configuration file, but still do not know how to run it smoothly.
I thought at first it was an issue related to the lacking of MySQL server and AWS account on my device. But, when I use it on my mac with home Wi-Fi, it is working like a charm without any installation and creation of MySQL server and AWS account. However, I still need to use this tool on my work PC because of input data privacy issue.
Does it mean I need to create an AWS account and adjust the network setting in it to access MySQL server on this URL 'locuscompare-us-west-2a.xxxxx.us-west-2.rds.amazonaws.com'? (Sorry that I am very new to AWS and MySQL.)
Please let me know how to run this tool behind a corporate proxy.

Can't connect to MySQL server (hosted by strato) error: 2013 lost connection to mysql server at 'reading initial communication packet' system error 0

Hi I am trying to connect to my MySQL DB which is hosted by strato. On their site I can create a DB and I did. I am able to connect via PuTTy like shown in this link. And I found the port, hostname etc as you can see but now I am trying to connect to the database via NaviCat but I keep getting the following error: 2013 lost connection to mysql server at 'reading initial communication packet' system error 0.
I configured NaviCat like this (as password I filled in the masterpassword strato provided me)
and this (as password I filled in the masterpassword strato provided me)
Screenshot of the error I am getting:
There is also a page on my hosters site with an tutorial on how to connect to their DB using PuTTy: link to page
Maybe you're wondering why I don't contect the host, it takes ages for them to reply...
What am I doing wrong why cant I connect how can I fix it?
If anyone can help me i would rlly appreciate it!
The manual says the hostname for a database connection should be
rdbms.strato.de
Or has this never been possible? I quote Can not connect to mysql database [strato]:
Connection posibilities(access) depends on your hosting package. But,
actually, remote connections to strato mySQL is not allowed(security
reasons). I have the same trouble with PowerWeb Basic.
The access is probably meant for applications you host with them, not running elsewhere (eg. at home).
If you want to work locally, perhaps they allow you to take a dump of your database that you can install locally? Do they have PHPMyAdmin?

"Host is not allowed to connect to this MySQL server" over network

I am attempting to connect Tableau on a client (Windows 7) to a MySQL Server 5.6 (on Windows Server 2012 R2) that is hosting my data warehouse. This server is hosted on my university's network. Here is what I have done so far:
created a user that has privileges it needs (I ran GRANT ALL PRIVILEGES ON the user with FLUSH PRIVILEDGES, based on some other stack overflow posts)
made sure the host specified in the user table is "%"
made sure there was nothing in the my.cnf file that would prevent external connections (again based on another stackoverflow post)
ensured that the edition of MySQL running on the server is 64 bit, like the version of Tableau I'm running
I still get the "[MySQL][ODBC 5.3(w) Driver]Host 'vpn240-74.vpn.utah.edu' is not allowed to connect to this MySQL server" error. This same error is thrown when I try to telnet to the port on the server MySQL is listening on.
I have found that this error persists whether I am connected via a vpn or on campus. I can RDP to the server in question, ping it, and found the firewall rule for the port I am using, so I don't think there is anything network related that is stopping me.
All my stackoverflow research says that error means MySQL is convinced that the user is not allowed to connect from that specific hostname, but I get the same error whether I change the entry in the user table to be "%" or the specific hostname from the error message.
Also I see that the Tableau MySQL driver I installed is a lower version number than the MySQL instance I'm trying to hit (5.3 vs 5.6) but that is the newest driver on the Tableau site that I can find.
Any help greatly appreciated.
Have you tried making an ODBC connection in your computer to your MySQL server and testing it that way?
Tableau can then connect via an ODBC connection made rather than the explicit Tableau MySQL driver. In Tableau under More Servers... Other Databases (ODBC) shows up at the very bottom.

SQL Server: getting error 26 after clicking on connect button

I have prepared a program with Visual Studio 2010 and I'm working with SQL Server 2008. Before 2 weeks ago, this connection was working properly. Now, I'm trying to use it again. When I'm clicking on the Connect button, it waits, and then gives this error:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found or
is not accessible. Verify that the instance name is correct and that
SQL Server name is configured to allow remote connections. (provider:
SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified.)
I googled this issue, but nothing helps.
I will be grateful to help me with this issue.
Do ensure that service is running. You can check this by writing this query on the query analyser as:-
IF EXISTS (SELECT 1 FROM sysprocesses WHERE LEFT(program_name, 8) = 'SQLAgent')
PRINT 'Running!'
ELSE
PRINT 'Not running';
From here:-
Make sure your server name is correct, e.g., no typo on the name.
Make sure your instance name is correct and there is actually such an instance on your target machine. [Update: Some application
converts \ to . If you are not sure about your application, please
try both Server\Instance and Server\Instance in your connection
string]
Make sure the server machine is reachable, e.g, DNS can be resolve correctly, you are able to ping the server (not always true).
Make sure SQL Browser service is running on the server. If firewall is enabled on the server, you need to put sqlbrowser.exe and/or UDP port 1434 into exception.
Open command prompt and execute this code:
For default instance : NET START MSSQLSERVER
For named instance : NET START MSSQL$

Tomcat7 MySQL Connection Error

I'm facing a perplexing problem. I've completed a jsf web app that utlizes hibernate and infinispan with Tomcat7 and tomcat-jdbc-pool as the connection pool provider.
It is being deployed to a Linode cluster w/ 2 nodes -- one database server and one production server.
I can run the app on my local environment using the exact same copy of Tomcat7 (I literally tarred the tomcat directory and promoted it to the server to debug this error) -- even when connected to the live database instance. Everything runs fine.
When I attempt to run the application from the production server I get a MySQLIO error:
Caused by: java.net.ConnectException:
Connection refused
Looking further up in the logs i see:
The last packet sent successfully to
the server was 1 milliseconds ago. The
driver has not received any packets
from the server.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:
Communications link failure
I can connect from the command line on the prodapp server just fine -- even using tcp:
mysql -h db01 -u user -p --protocol=tcp
But it just won't work running inside the Tomcat container. I've tried all kinds of things but I'm really stumped. It just seems strange that I can connect to the database server using the same copy of Tomcat7 locally but when deployed to production the same copy of tomcat7 can't connect -- even though I can connect from the command line on that production server ... I'm stumped.
Any help is greatly appreciated.
EDIT: Solved my problem after wasting too much good life on it. The answer was I'm stupid. Thanks to everyone who tried to help. I have the app moded w/ a dev and live mode and the connection pool was reading the dev mode this whole time. What really made it confusing is that the sessionfactory was moded to live so it would actually reach the live database and initialize a connection when it started up so i could see it connecting (and running meta data queries in the mysql log), but when it actually went to grab a connection from infinispan it blew up. Oh well -- at least it's working now. Thanks again.
If you're connecting to your MySQL database server from a different box, then you need to explicitly grant permission for that user account to connect from that IP.
You can do this whilst in the command line:
GRANT ALL PRIVILEGES ON *.* TO 'username'#'ip_address'
EDIT: Granting all permissions on all tables generally isn't required, be specific about what permissions you want to grant (http://dev.mysql.com/doc/refman/5.1/en/grant.html)
To see what permissions you currently have:
USE mysql;
SELECT * FROM users;
My apologies if I'm patronising you, just that this is the most common problem that I come across.