MySQL

Create MySQL configuration file (my.cnf) on MAMP

If you ever find yourself in need to adjust some MySQL settings and you're running a MAMP server on Mac OS X, you can always create a my.cnf file using the following command:

sudo cp /Applications/MAMP/Library/share/mysql/my-medium.cnf /Applications/MAMP/Library/my.cnf

You now have created your own my.cnf file where you can adjust some settings. Please make sure restart your MySQL instance after altering the configuration.

You have a few other starting point for creating a my.cnf file. MAMP ships with 5 configuration files for some typical settings. The filenames should be self explanatory:

./Library/share/mysql/my-huge.cnf
./Library/share/mysql/my-innodb-heavy-4G.cnf
./Library/share/mysql/my-large.cnf
./Library/share/mysql/my-medium.cnf
./Library/share/mysql/my-small.cnf

Update: Beware: The my.cnf file might enable binary logging. This may create huge log files (gigabytes). Check out webchick's post how to disable mysql binary logging.

Written on September 24, 2008 at 09:48, tagged as administration, MySQL, tips

MySQL server has gone away

I have had this one 2 times now. And it's always the same thing: too many fields in CCK.

Too many fields means too large queries to update the cache. And then MySQL goes down with this nice error message.

How to solve this? Increase the max_allowed_packet to a bigger number in your my.cnf (linux) or my.ini (windows).

If it's not there just add it.

max_allowed_packet=32M

Problem solved!

Written on August 06, 2008 at 14:36, tagged as administration, Drupal, MySQL, server management

Importing a UTF-8 database and keep special characters

This is a follow up to the post "Creating a UTF-8 database to work with special characters".

When you want to move your database from one server/database to another one, you generally create a sql dump file from the source database using the mysqldump command and then do an import into the destination using the mysql source statement or via shell redirection (<).

This is just a heads up. When you make the connection on the destination server/database, specify the --default-character-set=utf8 option.

You end up with something like:

mysql -u user -ppassword --default-character-set=utf8 database < "dump.sql"
Written on April 29, 2008 at 06:30, tagged as caveats, Drupal, i18n, MySQL

Creating a UTF-8 database to work with special characters

I'm a Dutch speaking person. So sometimes I have to make Dutch websites. The Dutch language uses some special characters that are not used in English. I'm talking about tremas, umlauts, ... (ë, â, ...). These characters can turn up weird on your website.

As soon as you start seeing those appearing on your website, you might be sure it has to do with character sets and encoding.

And since your website is build upon a database, your database should be the first thing too look at finding the cause of your problem.

So the first thing I do when creating my database is to make sure it uses the correct character set. In MySQL this is done by issuing the following statement:

create database my_database character set utf8 COLLATE utf8_general_ci;
Written on January 21, 2008 at 14:57, tagged as Drupal, i18n, MySQL

About

drupalcoder.com is a blog on all things Drupal in specific and LAMP on OS X in general. It is maintained by Davy Van Den Bremt, a Belgian (Drupal) web developer and designer living in Ghent. The goal of this blog is to log all interesting things that have crossed the writer's path while developing Drupal sites. You can read all about Davy's professional activities on his LinkedIn profile. If you want to get in touch, use the contact form.