简体   繁体   English

将 Mysql 表从 MyISAM 更改为 InnoDB

[英]Change Mysql table from MyISAM to InnoDB

I have a project i have been running for a while that is getting a much larger database of around 6GB.我有一个项目已经运行了一段时间,它正在获得一个大约 6GB 的更大的数据库。 1 of the database tables keeps getting corrupted or is crashing more often now. 1 个数据库表现在不断损坏或更频繁地崩溃。

Table: 19 779 121 MyISAM utf8_unicode_ci 5,4 GB表:19 779 121 MyISAM utf8_unicode_ci 5,4 GB

The table is so big as stores user statistics that each user can access on my website.该表是如此之大,以至于存储了每个用户都可以在我的网站上访问的用户统计信息。 so a lot gets written and read from that table all the time.所以很多时间都是从那个表中写入和读取的。

As i understand it the recommendation for big tables are to change MyISAM to InnoDB to keep this from happening as InnoDB can handle larger amounts of data faster and better?据我了解,对大表的建议是将 MyISAM 更改为 InnoDB 以防止这种情况发生,因为 InnoDB 可以更快更好地处理大量数据?

If the answer is yes i wonder how i could in the best way change the table to InnoDB?如果答案是肯定的,我想知道如何以最佳方式将表更改为 InnoDB?

i tried to do ALTER TABLE my_table ENGINE = InnoDB;我试着做ALTER TABLE my_table ENGINE = InnoDB; but phpmyadmin just timed out when i did it and no change is done to the tables.但是 phpmyadmin 只是在我执行此操作时超时,并且没有对表进行任何更改。 I also tried to do this with SSH.我也尝试用 SSH 来做到这一点。 i got the error ERROR 2013 (HY000): Lost connection to MySQL server during query.我收到错误ERROR 2013 (HY000): Lost connection to MySQL server during query。 i have 5GB of ram on the server.我在服务器上有 5GB 的内存。 each time i do this the ram when i watch HTOP is saying 14.5GB/5.00G before i get that error.每次我这样做时,当我看到 HTOP 说 14.5GB/5.00G 时,内存就会出现错误。 Is it because i do not have enough RAM?是不是因为我没有足够的内存? If yes, what should i do?如果是,我该怎么办?

And in general.并且在一般情况下。 Do Anyone got any suggestions in general on what to do with the table getting corrupt / crashing ?有没有人对如何处理表损坏/崩溃有任何建议?

What you can do is create a new table with the same structure but InnoDB as an engine.您可以做的是创建一个具有相同结构但 InnoDB 作为引擎的新表。 Then you can move your data from the myISAM table to this new table, chunk by chunk.然后,您可以将数据从 myISAM 表中逐块移动到这个新表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM