MySQL Error 2013 - mysql

I am facing connection failure to MySQL problem when I run my program for more than couple of days.MySQL Error Code is 2013 while connecting to Database. MySQL server and client programs are both on same machine. I am using FC5 as my OS and MySQL version is 5.0.18. Can anybody throw some light on this?
I am getting mysql error 2013 while calling mysql_real_connect()...
Any help is appreciated.

Try using localhost, instead of your own IP.
I don't know why, but this immediately fixed the problem for me.
I would be very grateful if someone could clarify
why this worked, all of a sudden.

Sounds like a firewall issue. Have you tried disabling the firewall temporarily?
Another possible solution involves edition the startup script as mentioned here and commenting out the following line:
SKIP=skip-networking
A third possible solution is mentioned here. The user tried to access an InnoDB database and InnoDB support was accidentially deactivated for the MySQL server.
(new) I found this official MySQL article which has lots of approaches to solve the problem. Did you modify the wait_timeout system variable?

Here's an answer you might not expect. I had encountered the same problem. MySQL Error 2013. Here are the symptoms:
PHPMyAdmin fired off 2013 and error 95.
I could shell into the MySQL monitor, but it took an inordinately long time to start. I could view tables and everything worked once the command line utility started
The server took a LONG time to stop and restart.
No errors in the MySQL error log.
I work with a good sysadmin who checked netstat -tn, which yielded the answer:
tcp 0 0 [my.srv.ip]:3306 184.73.87.215:59271 ESTABLISHED
tcp 0 1 [my.srv.ip]:38138 184.73.87.215:113 SYN_SENT
The IP resolves to Amazon Web Services. Some prick was leeching onto my 3306, even though everything but port 80 is allow-only. It's time to review my firewall rules.
There were no new tables, and mtop didn't show any activity, but I found a ton of these in the auth log:
Apr 19 15:14:52 magic2 mysqld[18953]: refused connect from ec2-184-73-87-215.compute-1.amazonaws.com
Apr 19 15:18:02 magic2 mysqld[18953]: refused connect from ec2-184-73-87-215.compute-1.amazonaws.com
After blocking the offending IP in iptables, the problem suddenly went away. Sneaky Bastards. The moral of this story is: What looks like bug, might be a hacker.
bz

Check your my.cnf. Set your bind-address to the server's IP address. Solved the issue for me. NO ONE seemed to know the answer to that one!

My fix was - change 'localhost' to '127.0.0.1'

It could be a network error that caused the TCP/IP connection to drop, or the wait_timeout was exceeded on the server; the latter can actually be useful in keeping the # of open connections down, but the app will then need to handle errorcode 2013 correctly!!

Related

Unable to connect to localhost:3306 (2003) for MySQL 8.0.21 on Windows

I am using MySQL workbench to connect to my local server. Everything was running fine and suddenly I jumped in a connection refused errors. I tried restarting the server again and again. Clearing temp files and also restarted my machine. I found this post from which I tried a couple of things like net stop and stopping the process from the services list but in the services list it shows as below:
I waited like for 30 mins but still, the service is not stopped.
Also, below is the screenshot for MySQL workbench when I try to start the server:
Is there anything specific which I need to do in order to resolve this error:
So, I resolved my own problem in this way. I referred the documentation for this particular error and for my error which is of 2003 type it said that look for mysqld.exe process in task manager and if you don't find any then start the server. But, in my case I found 2 mysqld.exe processes running. So, I killed those processes and restarted the server. It worked!!
Might help someone someday :)

MariaDB client connection aborted after 60 sec. Seems to relate to SSL. Would like to find out why

I'm running MariaDB v10.0.14 on a Windows 2012R2 Server, and I work locally from a Win7 machine. I'm limiting this problem to using the command line client tool. I am encrypting the connection to the server DB with SSL. I can connect and issue commands, however after being idle for 60s I get:
ERROR 2013 (HY000): Lost connection to MySQL server during query
When I re-issue the command I get:
ERROR 2006 (HY000): MySQL server has gone away.
No Connection. Trying to reconnect...
Then the client reconnects and runs the command. I don't know why this is occurring and am worried it may affect DB users' connections. Some troubleshooting:
When I connect without SSL this does not occur
I have been ignoring this issue for a while so can not say what change may have led to this. I certainly remember connecting with SSL in the past and not having these timeouts.
I can RDP to the server, connect to DB with command line tool and SHOW FULL PROCESSLIST. I can see the localhost connection plus the remote client connection. When the client has just been started I see Command as 'Sleep' and State as 'cleaning up'. I can issue commands from the client. When Time > 60 State changes to Null and the client shows the above symptoms.
I've read through this, tried all standard suggestions but can't even seem to find any mention of this behaviour. Is it normal?
Wait_timeout and interactive_timeout are set at 28800 so I don't think this is the problem.
net_read_timeout=30 and net_write_timeout=60 but these are tiny commands
connect_timeout=10 but connection is not the issue.
Credentials and permissions are fine as I can connect originally.
Error log has entries corresponding to this event as:
Aborted connection xxx to db: <dbname> user: '<user>' host: '<host>' (Unknown Error)
Firewall logs show that traffic seems to be flowing just fine.
I took a capture of network traffic on the server and saw the below. The blue is the original connection. In orange you can see that at 73s I issue a new command which is met in red with [FIN, ACK] then [RST, ACK] from the server. The green afterward is when the command is reissued and the reconnection occurs. Note the change in client port. Handshakes seem to be fine. Beyond that I'm lost. I'm a data guy, not a network guy.
Anyone have any insights or ideas? Thanks.
Output for
show variables like '%timeout%';
(can't post more than 2 links. I should answer some questions)
connect_timeout=10
deadlock_timeout_long=500000000
deadlock_timeout_short=10000
delayed_insert_timeout=300
innodb_flush_log_at_timeout=1
innodb_rollback_on_timeout=OFF
interactive_timeout=28800
lock_wait_timeout=31536000
net_read_timeout=30
net_write_timeout=60
slave_net_timeout=3600
wait_timeout=28800
Sorry if it comes a bit late, but the reason is this bug https://jira.mariadb.org/browse/MDEV-9836 . SSL connection were aborted after net_read_timeout (which is quite short) not after net_wait_timeout.

XAMPP Mysql 2002 error

So I have been trying to get XAMPP up and running for awhile now. I see there is plenty of documentation on this problem but most of them don't seem to be helping my situation so I would really appreciate someones help walking me through this.
Ok when I started apache wouldn't start but when I changed it so that it would be using port 85 that at least started. My next problem has been with MySql. It is currently running on port 3306 (I had something else that was using that port but I deleted it) when I click to start MySql it just says it is attempting to start but doesn't do anything. When I go to phpMyAdmin I get this error message
2002 - No connection could be made because the target machine actively refused it.
The server is not responding (or the local server's socket is not correctly configured).
Are there any procedures I can go though to get this thing up and running?!

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 0

I am getting the following error
ERROR 2013 (HY000): Lost connection to MySQL server at
'reading authorization packet', system error: 0
when trying to connect to my MySQL server.
What I am doing:
I have Master - Slave replication in MySQL that is working and just added load balance capabilities using F5.
I have configured the F5 according to their site.
But when I am trying to connect to my MySQL server using the IP that the F5 was configured with I get
ERROR 2013 (HY000): Lost connection to MySQL server at
'reading authorization packet', system error: 0
Any ideas?
Update on my progress : ZERO
- i am getting the same error
I get no entries in the /var/log/secure as if somebody would try to authenticate coming form the ip where i had created my load balance server.
No enties in the mysql error log.
The command - returns nothing
mysql> SHOW GLOBAL STATUS LIKE 'Aborted_connections';
Empty set (0.00 sec)
I've already altered my my.cnf file and add the
[mysqld]
skip-name-resolve
Alterd the connect_timeout to 10.
So it seems i get no response for the server i have created on my F5
I finally convinced the F5 admin to pass me the log for the F5 server and i have exctraced all i need form it.
Here is the output :
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_ACCEPTED>: BIG-IP MySQL Proxy -- clientside initial connection
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_ACCEPTED>: BIG-IP MySQL Proxy -- clientside responding with server WELCOME packet
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_DATA>: BIG-IP MySQL Proxy -- clientside authenticated flag not set
Jan 28 15:46:39 tmm err tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_DATA>: BIG-IP MySQL Proxy -- mysql client: attempting to do something before authentication
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <LB_SELECTED>: BIG-IP MySQL Proxy -- serverside selected pool /Common/foss-mysql-slave_pool node SLAVE-IP
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <CLIENT_CLOSED>: BIG-IP MySQL Proxy -- clientside connection closed from MASTER-IP(XXXXXXX)
Jan 28 15:46:39 tmm debug tmm[6459]: Rule /Common/iRule-f5_mysql_proxy <SERVER_CLOSED>: BIG-IP MySQL Proxy -- serverside connection closed from node SLAVE-IP(XXXXXXXX)
I've replaced the ip for security sake !
just as an extra - and i think is here the problem - my mysql version is 5.1.69-log
Thx All
From documentation:
More rarely, it can happen when the client is attempting the initial
connection to the server. In this case, if your connect_timeout value
is set to only a few seconds, you may be able to resolve the problem
by increasing it to ten seconds, perhaps more if you have a very long
distance or slow connection. You can determine whether you are
experiencing this more uncommon cause by using SHOW STATUS LIKE
'aborted_connections'. It will increase by one for each initial
connection attempt that the server aborts. You may see “reading
authorization packet” as part of the error message; if so, that also
suggests that this is the solution that you need.
Try increasing connect_timeout in your my.cnf file
Another style:
MySQL: Lost connection to MySQL server at 'reading initial communication packet'
At some point, it was impossible for remote clients to connect to
the MySQL server.
The client (some application on a Windows platform) gave a vague
description like Connection unexpectedly terminated.
When remotely logging in with the MySQL client the following error
appeared:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
On FreeBSD this happens because there was no match found in /etc/hosts.allow. Adding the following line before the line saying ALL:ALL fixes this:
mysqld: ALL: allow
On non-FreeBSD Unix systems, it is worth to check the files /etc/hosts.allow and /etc/hosts.deny. If you are restricting connections, make sure this line is in /etc/hosts.allow:
mysqld: ALL
or check if the host is listed in /etc/hosts.deny.
In Arch Linux, a similar line can be added to /etc/hosts.allow:
mysqld: ALL
This is usually caused by an aborted connect. You can verify this by checking the status:
mysql> SHOW GLOBAL STATUS LIKE 'Aborted_connects';
If this counter keeps increasing as you get the lost connections, that's a sign you're having a problem during connect.
One remedy that seems to work in many cases is to increase the timeout. A suggested value is 10 seconds:
mysql> SET GLOBAL connect_timeout = 10;
Another common cause of connect timeouts is the reverse-DNS lookup that is necessary when authenticating clients. It is recommended to run MySQL with the config variable in my.cnf:
[mysqld]
skip-name-resolve
This means that your GRANT statements need to be based on IP address rather than hostname.
I also found this report from 2012 at the f5.com site (now protected by login, but I got it through Google cache)
It is likely the proxy will not work unless you are running BIG-IP 11.1 and MySQL 5.1, which were the versions I tested against. The MySQL protocol has a habit of changing.
I suggest you contact F5 Support and confirm that you are using a supported combination of versions.
I've struggled a lot with this error. Tried every single answer I found on the internet.
In the end, I've connected my computer to my cell phone's hotspot and everything worked. I turned out that my company's internet was blocking the connection with MySQL.
This is not a complete solution, but maybe someone faces the same problem. It worths to check the connection.
I solved this by stopping mysql several times.
$ mysql.server stop
Shutting down MySQL
.. ERROR! The server quit without updating PID file (/usr/local/var/mysql/xxx.local.pid).
$ mysql.server stop
Shutting down MySQL
.. SUCCESS!
$ mysql.server stop
ERROR! MySQL server PID file could not be found! (note: this is good)
$ mysql.server start
All good from here. I suspect mysql had been started more than once.
My case was that the server didn't accept the connection from this IP. The server is a SQL server from Google Apps Engine, and you have to configure allowed remote hosts that can connect to the server.
Adding the (new) host to the GAE admin page solved the issue.
I have a mac but would assume all linux are the same for this part...
In my case I got this:
2018-12-03 11:13:27 - Start server:
2018-12-03 11:13:27 - Server start done.
2018-12-03 11:13:27 - Checking server status...
2018-12-03 11:13:27 - Trying to connect to MySQL...
2018-12-03 11:13:27 - Lost connection to MySQL server at 'reading authorization packet', system error: 0 (2013)
2018-12-03 11:13:27 - Assuming server is not running
I ran this:
sudo killall mysqld
And then started the mysql again through mysqlworkbench although in your case it might be like this:
mysql.server start
*sidenote: I tried running mysql.server stop and got this Shutting down MySQL
.... SUCCESS! but after running ps aux | grep mysql I saw that it hasn't really shut down...
I use several mysql connections (connecting to different sets of databases) in localhost.
This happened to me after I shut my computer down and mysql was not properly shutdown. After starting my machine I was able to successfully connect to multiple db connections except one (I used this a lot before my machine shutdown).
As per the instructions in this posts I doubled connect_timeout but I was not able to connect to that one database connection.
I restarted my machine and i can successfully connect now. This will help you unblock yourself but it'd be great if it can be fixed without restarting the machine.
Another concern is: connection_timeout seemed to me delay related problem but I was getting the error immediately in localhost when there is no network in the equation.
In my case, it happened when there were a lot of connection to the MySQL server (15,000 connections) and the free memory was about 120M . After I added more memory to the server, the error was gone.
I scratched my head about this error for 3 days. I tried tweaking permissions on the database, new users from different IPs in the Users table, adjusting the bind-address in a bunch of different ways, comparing my my.cnf file to a known working server, firewall changes, upstream firewall changes, hosts.allow/deny...none of them worked.
Then I looked not at mysql/error.log (which came up empty) but my journalctl -xe log and low and behold, it couldn't read my /etc/hosts.allow and my /etc/hosts.deny file.
chmod 644 hosts.allow
chmod 644 hosts.deny.
All better now.
Another possibility can be connection reset from the TCP wrappers (/etc/hosts.deny and /etc/hosts.allow). Just check what is coming in from the telnet to port 3306 - if it is nothing, then there is something is in the middle preventing communication from happening.
I've created my account just to add this bit of information to this old question, because nowhere on the web I found any reference to the cause of my problem which I eventually found.
(Adding it here cause this is the top google result, also when adding PHP as search term)
In PHP 7.4 when you fork a process (I know, who does this??) that has an active MySQL connection, the connection will get messed up and spit out the OP's error.
just reinitialize/recreate the connection in each forked process after the forking, this will fix it.
Hope it this helps anybody.
I got both errors: mostly reading initial communication packet and reading authorization packet one time. It seems random, but sometimes I was able to establish a connection after reboots, but after some time the error creeped back.
Avoiding the 5GHz WiFi in the client seems to have fixed the issue. That's what worked for me (server was always connected to 2.4GHz).
I tried everything from server versions, odbc connector versions, firewall settings, installing some windows update (and then uninstalling them), some of the answers posted here, etc... lost my entire sleep time for today. Super tired day awaits me.
If you get this when using DevDesktop - just restart DevDesktop!

Why is connecting to MySQL server so slow?

I use JDBC to connect to MySQL. When it’s at localhost:3306, everything is OK.
But when I move my application to another computer in the intranet, and use <Intranet-IP>:3306 to connect to the MySQL database, it takes about 1 minute to connect to MySQL successfully. What’s up with this?
Well it could be a DNS problem. You can disable DNS host name lookups by starting mysqld with the --skip-name-resolve option in the configuration file.
Read here for more details: http://dev.mysql.com/doc/refman/5.0/en/host-cache.html
The --skip-name-resolve worked great for me.
To make it permanent, I just add this line at the end of file my.ini in the [mysql] section:
skip-name-resolve
And voilá! Transactions now fly!
For me it was this solution I found here, If IP6 connectivity is enabled, connection to "localhost" may be slow, instead use the ip address, 127.0.0.1. This worked for me.
my mysql slow to connect problem was solved by this solution
firewalls, Internet, routing etc etc slows down your connection.
You should put your database on a intra net instead. Keep it local and behind your big firewall. You can of course have firewall and security between computers. I'd recommend that you didn't expose your mysql database connection to the Internet unfiltered that way.
comment / finding to a really REALLY old question.
background - typical: connecting from windows (various) to sql server on win or linux server slow ... multiple seconds (even from win client on VBox to server on same host)
skip-name-resolve, dns-bind - tried all sorts, regardless no effect.
Looked at the manual - connection string options - no time to learn what they mean, one-by-one set-and-try - as long as nothing breaks.
adding sslmode=none; to connection string ... connecting in literally less than 1/10th the time. sub-second connections, milliseconds!
Note:
It's in a small office private LAN so don't GAS any security FUD
... It works ... I'll take it.