These are not server problems they are software problems.
- I would back up the tables you have now
- then truncate the data in the tables
- correct any column type errors
- then repopulate the tables with new data using your PHP script
- if the cpu use is too high then -- you have some errors or a memory leak in your PHP script
.