MySQL connection loss during query - mysql

I am working on converting unix time to readable time.
It is necessary to insert a 6gb .txt file into my database
(XAMPP V3.2.2 , MYSQL workbench 5.2.34).
I have written the SQL query to convert unix time but whenever i run the query, Mysql workbench will crash
(error:2013.lost connection to database during query.).why?
my SQL query:UPDATE database.database SET readable_time=from_unixtime(unix_time);

Increasing net_read_timeout solves this problem
From doc:
Sometimes the “during query” form happens when millions of rows are being sent as part of one or more queries. If you know that this is happening, you should try increasing net_read_timeout from its default of 30 seconds to 60 seconds or longer, sufficient for the data transfer to complete.
Click here for more info.
Please check this post - Error Code: 2013. Lost connection to MySQL server during query

As you are talking about an insert, understand that the 'Workbench' loses the connection, but the query continues to execute in the 'server'. That is, the workbench can no longer update you on the status changes for that query execution. But, the execution of the query keeps continuing behind screens.
You might want to run show processlist to see if the insert process is still running or not.
However, while fetching data from the database, you might have to update your timeout settings.

Related

some of execution failed due to unable connect any specific mysql hosts vb.net

i have look around regarding this issues. Recently i faced issues so called unable to conenct any specific mysql server in vb.net. Means in middle of execution of MYSQL, some of execution might interrupted and missing out. So let say i execute 3 mysql operation update, insert and delete, so in middle of execution of this 3 operation, suddenly it pop out "unable to connect any specific mysql HOSTS" and execution for update or insert might missed out. Sometime some columns of execution is missing out and make the execuation incomplete..I tried to change the connection timeout to longger time for 90sec, but still doesnt help. Any suggestion?
You mean instead of doing this
sqlQuery="Update"
executeQuery(sqlQuery, Connection2)
sqlQuery="Update"
executeQuery(sqlQuery, Connection2)
sqlQuery="Insert"
executeQuery(sqlQuery, Connection2)
better doing this
sqlQuery="Update"
sqlQuery="Update"
sqlQuery="Insert"
executeQuery(sqlQuery, Connection2)

MySQL Workbench kicks me off before query runs

I'm using MySQL workbench to run a query. The query is reasonably big. When I limit the results to say 50 records the results are as expected. But when I remove the limit, the query runs for ~ 5 minutes then prompts me to re-enter my password. After doing so I see the query has not run and has stopped working.
It seems like there is a setting that kicks me off after a certain amount of time but I cannot see it in the drop down menus.
Has anyone experienced this? Any advice?
** Update**
Query ran and Workbench says results returned but they are not and I got the screen shot error pop up here:
It sounds like one of three things are the likely culprit.
MySql Workbench may be timing out.
This may help with #1
Go to Edit -> Preferences -> SQL Editor and set to a higher value this
parameter: DBMS connection read time out (in seconds). For instance:
86400.
Close and reopen MySQL Workbench. Kill your previously query that
probably is running and run the query again.
The mySQL server is timing out
You will need access to the server's timeout configuration
Something network related (but far less likely if your timeout happens consistently at around 5 mins)
There are a number of factors that might need adjusting.
If #2, you will need access to the server's timeout configuration
If #3, well, there are a number of factors that might need adjusting.

Error #1159 with MySQL FEDERATED table and one kind of query

I have one problem with FEDERATED table in MySQL. I have one server (MySQL version 5.0.51a), who serve to store client data and actually nothing more. The logic database are stored in another server (version 5.1.56), sometimes it should handle that data from first server. So the second server have one FEDERATED table, which connect to the first server.
Actually, it has worked without any problems, but recently I got strange errors with this solution. Some kind of queries on second server cannot be performed correctly.
For example SELECT * FROM table - doesn't work. It hangs exactly 3 minutes and then gives:
Error Code: 1159 Got timeout reading communication packets
Ok, I checked table on the first server and it's Ok. Then I tried some another queries to FEDERATED table and they work...
For example, query like SELECT * FROM table WHERE id=x returns the result. Probably it could have problem with size of result, so I tried query with dummy WHERE-clause like SELECT * FROM table WHERE id > 0 - and it also works...
Finally I found a "solution", which helped only for two days - on the first server I made a copy of table, and on second server I re-declared a new FEDERATED table with new connection string to this copy. And it works, but after two days the same problem with new copied table.
I've already talk with both server providers, they see no problems, everything seems to work and other hosting provider is the causer of problems.
I've checked all variables in MySQL and there is no timeout parameter with 3 minutes etc. So how can I deal so kind of problems? It seems to be something automatic on network or database side, but I don't know, how to detect the reason of problems.
Do You have any ideas?
You may try checking MTU size settings for network interfaces on both servers.
This warning is logged when idle threads are killed by wait_timeout.
Normally, the way to avoid threads getting killed by wait_timeout is to call mysql_close() in scripts when the connection is no longer needed. Unfortunately that doesn't work for queries made through federated tables because the query and the connection are not on the same server.
For example, when a query is executed on server A of a federated table (pointing to data on server B), it creates a connection on server B. Then when you run mysql_close() on server A it obviously can not close the connection that was created on server B.
Eventually the connection gets killed by mysql after the number of seconds specified in "wait_timeout" have passed (the default is 8 hours). This generates the warning in your mysqlerror.log "Got timeout reading communication packets"

Error code: 2013: Lost connection to Mysql server during the query.. How can improve this query

I am getting the error stated in my post title. I have two tables. The first one, large is over than 4000,000 records and the second, small one is arounf 7000 records. I want to search for the value in the samll table and if found, I want to extract the whole record from the large table. The command never executed and always lose the connection with the database. I tried to limit the out put to 50 records only, the same thing happens. Please help me. If I need something like indexing (I read this might solve such performance problems, please clarify to me how. I'm not a DBA).
select * from db.large, db.small
where large.value=small.value;
*EDIT: * I use MySQL workbench 5.2.41 CE.
At one point on a previous project, I could actually crash the MySQL server reproducibly with a pretty simple query. In the code that called the database, I saw the same error message. Can you verify that the MySQL server's process ID is the same before and after the query? Chances are that your OS restarts the MySQL server immediately after the crash, and the MySQL command line client automatically reconnects (though it emits a notice when it does).

Is query correct if connection was lost during it?

After establishing a remote connection to a MySQL server (using the MySQL command-line front-end) I started executing a very long stored procedure (I estimate that it may take longer than 7 hours) but in the middle of it I received the error:
ERROR 2013 (HY000): Lost connection to MySQL server during query
So I guess that my query got timed-out. This procedure just stores some values in a
previously empty table.
After receiving this error and re-establishing the connection to the server I could
verify that the procedure somehow continued executing. And some time later I also verified
that the previously empty table now has some rows.
My question is, Can I trust that the procedure's execution was correct even though the
connection was lost?
First, 7 hours seems too long. If the incompolete result bothers you, you could add some save point when N queries done, and combine the N queries into a single transaction. Then, Every time your procedure stops exceptionally, you could load the point you last saved.
I also suggest you could try to select the source data into your local pc, and make some script to get the result, then upload it to target table. This will reduce overhead on db server.