How to bypass the error “Cannot add or update a child row: a foreign key constraint fails” when importing a MySQL dump file

If you encounter the error “Cannot add or update a child row: a foreign key constraint fails” when you import a MySQL dump file, you can bypass the foreign key checks by setting the following line at the top of your MySQL dump file:

SET foreign_key_checks = 0;

Note that the line should be put before any other SQL query in the dump. Save the file and try to import it once again. This time it should be imported silently.

If you are proficient in the SQL, you might try and suggest other alternative solutions.

A short update:

The above solution might be rough and not well working. If you experience troubles and errors after the import, you can try to replace the above line with:

SET SQL_MODE=”NO_AUTO_VALUE_ON_ZERO”;

The second solution worked better for me particularly.

How to disable the cache usage in SugarCRM

SugarCRM is configured by default to use external cache and if the external cache storage is not available, it will produce a warning or error.

The specific cache handlers can be disabled with the following lines:

‘external_cache_disabled_apc’ => ‘true’, //if set to true will disable apc external cache.
‘external_cache_disabled_memcache’ => ‘true’, //if set to true will disable memcache external cache
‘external_cache_disabled_zend’ => true, //if set to true will disable zend external cache

To disable the caching completely, use the following line:

‘external_cache_disabled’ => ‘true’,

The lines should be placed in the beginning of the SugarCRM’s configuration file – config.php.