2

I had this error when I tried to add a primary key to my table:

lost connection to MySQL server during query

And this is my query:

ALTER TABLE test ADD  PRIMARY KEY (ORDER_ID);


My database configuration timeout:

+----------------------------+----------+
| Variable_name              | Value    |
+----------------------------+----------+
| connect_timeout            | 10       |
| delayed_insert_timeout     | 300      |
| innodb_lock_wait_timeout   | 50       |
| innodb_rollback_on_timeout | OFF      |
| interactive_timeout        | 28800    |
| lock_wait_timeout          | 31536000 |
| net_read_timeout           | 30       |
| net_write_timeout          | 60       |
| slave_net_timeout          | 3600     |
| thread_pool_idle_timeout   | 60       |
| wait_timeout               | 28800    |
+----------------------------+----------+
informatik01
  • 16,038
  • 10
  • 74
  • 104
mak_doni
  • 565
  • 1
  • 10
  • 29
  • https://stackoverflow.com/questions/8859353/alter-table-to-add-a-composite-primary-key – Gopala Raja Naika Feb 14 '19 at 17:19
  • @RajGopal He's not trying to add a composite key. – Barmar Feb 14 '19 at 18:10
  • 1
    If the table is very large, indexing all the rows can take time. I suspect primary keys are the worst, because it has to rearrange the row data. – Barmar Feb 14 '19 at 18:12
  • Are you running this from MySQL Workbench? It has a default timeout of 600 seconds. https://stackoverflow.com/questions/10563619/error-code-2013-lost-connection-to-mysql-server-during-query – Bill Karwin Feb 14 '19 at 19:13

0 Answers0