MySQL

phpMyAdmin "Save as file" file name template

Submitted by charles on
When using phpMyadmin to backup a MySQL database, there is an option near the bottom to save as a file. When you use this option, you can make your life easier by using a file name template that automatically names the backup file for you. By default it is the database name, but I find it useful to put a timestamp on it as well. To do that, use the following in the file name template field: %Y%m%d%H%M%S-__DB__ This will save your files in the following format: 20070815152612-databasename.sql

Drupal node insert error related to the sequences table

Submitted by charles on

I recently added a lot of data to a drupal site by running some scripts that I'd created in php. This was to save me the time of manually capturing the content. After successfully adding the content, when I tried to add a new content item, I got the following error: Warning: Duplicate entry '503-503' for key 1 query: INSERT INTO node (nid, vid, title, type, uid, status, created, changed, comment, promote, moderate, sticky) VALUES (503, 503, 'World Bank ', 'content_organisation', 1, 1, 1171017191, 1171017191, 2, 1, 0, 0) in It turns out that Drupal uses the sequences table to keep track of what the highest id in certain tables is. I had forgotten to update this table with the id of the most recent node that I'd added.

MySQL case sensitivity of table names between windows and linux systems

Submitted by charles on
While I normally stick to all lowercase table names for my MySQL database tables, I often have to come in on a project where the database has already been set up using a mixture of lower and uppercase table names. Because windows is case-insensitive, when you create a MySQL table or export tables for use on a linux system, all table names will be lowercase by default. This will cause problems when the dump imported into MySQL on linux, as any calls to the original mixed case tables will result in errors, as these tables don't actually exist.