Posts Categorized: mySQL

Mysql keeps crashing on Ubuntu

Posted by & filed under mySQL.

Mysql ran out of resources (either Ram or swap file) and died every 2 to 4 days. Turns out is was postfix using up all the memory due to some spammy process. I didn’t need postfix running so I just stopped it and solved the mysql issue.    

Foreign key restraints

Posted by & filed under Magento, mySQL.

Trying to import a Magento table into a database (drop table if exists) I got an error: The way to get round this is to remove the foreign key constraint CHECK, delete the table, then add the check again:

Handle mysql_query() error without a variable

Posted by & filed under mySQL, PHP.

Thought this was a neat way of testing/handling query errors without assigning the result to a variable because you don’t need a variable unless you are using SELECT. mysql_error() returns empty string if there was no error, which evaluates to false, as pointed out by jakub-arnold in this post

PHP mySQL Database backup

Posted by & filed under mySQL, PHP.

There are times when you need to get an SQL dump of a database but you don’t have access to management tools AND system(), exec() and passthru() commands are disabled. This script from David Walsh will do the trick: