Archive for the 'MySQL' Category

MySQL compare NULL equivalent to an empty string

Nearly all MySQL’s string functions return NULL when a NULL value is used for comparison. Although this is correct sometimes it is useful to compare NULL as being equalivalent to an empty string (although they are technically different). One exception in MySQL’s string functions is the CONACT_WS function as this skips NULL parameters after the […]

MySQL slow query log

The MySQL slow query log enables you to log all queries that take longer than a specified number of seconds to execute.  This should help identify any queries that are not performing sufficiently. All that is required is two additional lines in the MySQL configuration file “my.cnf” in the [mysqld] section. 123[mysqld] log-slow-queries = /var/log/mysql-slow.log […]

MySQL export to CSV

Saving the results of a MySQL query in a format that Excel can use

Creating a MySQL unicode UTF-8 database

Here’s the syntax for creating a UTF-8 database in MySQL as I can never remember it! 1CREATE DATABASE `databasename` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;