0

I want to make an average of forex_askprice and forex_bidprice and insert into forex_midprice. like this

update eurusd_tickdata_2017 set forex_midprice=(forex_askprice+forex_bidprice)/2 

But I met this error

2003 - Can't connect to MySQL server on 'localhost' (10061 "Unknown error") 时间: 759.205s'

There are around 40,000,000 rows in the table eurusd_tickdata_2017

enter image description here

flyingfox
  • 13,414
  • 3
  • 24
  • 39
  • It's not an error with the query, you simply don't seem to be able to connect to the server. Since we don't know how you're trying to connect, it's kinda hard to help. – ADyson Jul 19 '18 at 10:13
  • there are 21704041 rows – SHENGNAN LI Jul 19 '18 at 10:15
  • It's nothing to do with how many rows you have. The error is saying you cannot even connect to MySQL, never mind run any queries. Maybe some of these will help (if MySQL is running on Windows) https://stackoverflow.com/questions/10892689/cant-connect-to-mysql-server-on-localhost-10061-after-installation . If not, then search on google for "2003 - Can't connect to MySQL server on 'localhost'" and try some of the other results which appear, in case there are useful suggestions relating to your particular situation. – ADyson Jul 19 '18 at 10:15
  • @SHENGNANLI as ADyson said,it has nothing to do with your rows amount,you can only update one row to check that – flyingfox Jul 19 '18 at 10:18
  • Thanks, everyone. I already connect to MySQL. But every time I run this ''update eurusd_tickdata_2017 set forex_midprice=(forex_askprice+forex_bidprice)/2 '', it always meet the same error – SHENGNAN LI Jul 19 '18 at 10:19
  • well it seems like maybe your connection has been dropped since you last connected. Can you run any other queries on the same database? Just try some simple SELECT query to test it. – ADyson Jul 19 '18 at 10:24
  • I've run this 'SELECT COUNT(*) from eurusd_tickdata_2017', and it works. I wonder maybe there are too many rows to update, so it finally lost the connection. – SHENGNAN LI Jul 19 '18 at 10:32
  • does it wait some time after starting the query before you get this error? – ADyson Jul 19 '18 at 10:32
  • Yes, it works when I start the query but lost connection after running for minutes – SHENGNAN LI Jul 19 '18 at 10:36
  • I suggest maybe running the update in batches. Or perhaps you can increase the query timeout length. I'm not an expert on the latter, sorry, but either someone else can answer or you can google whether it's possible to do that. – ADyson Jul 19 '18 at 10:56

2 Answers2

0

it was the problem on your configuration settings of your database source like connection look up this video for your issue.

https://www.youtube.com/watch?v=ab25N34RO8w

sumanth
  • 36
  • 1
-2

It looks like your MySQL server is not installed. you can check steps & install from link - MySQL on Windows

Community
  • 1
  • 1
D P
  • 328
  • 1
  • 8