A Little Noise

23Apr/092

Flour Power

(two months ago)
Iona: Daddy, am I going to marry you when I get big?
Daddy: No, you'll marry someone else, and the two of you will have your own family.
Iona: (in tears) I don't want to leave! I want to stay with you and mommy!

(last week, after passing the display cakes in the bakery)
Iona: Daddy, what kind of cake did you and mommy have at your wedding?
Daddy: I'll show you a picture when we get home.

Our Wedding Cake

(a few minutes later)
Iona: Daddy, I think it will be ok if I marry someone else and we have our own family.

Filed under: Kids 2 Comments
9Apr/093

errno: 121 (Duplicate key) with CREATE TABLE

Trying to create a table, and getting something like this?

ERROR 1005 (HY000): Can't create table '<db>.<table>' (errno: 121)

Discovered that perror 121 says this?

MySQL error code 121: Duplicate key on write or update

Really confused how you might get a duplicate key error while creating a table?

If the table you're trying to create includes a foreign key constraint, and you've provided your own name for that constraint, remember that it must be unique within the database. Run this query to see if that name is in use somewhere:

SELECT
  constraint_name,
  table_name
FROM
  information_schema.table_constraints
WHERE
  constraint_type = 'FOREIGN KEY'
  AND table_schema = DATABASE()
ORDER BY
  constraint_name;

(If you're still on 4.1 or earlier,

mysqldump --no-data yourDbName | grep CONSTRAINT

to get a similar list)

Thanks to [raymond] on Freenode.

Filed under: MySQL FAQ 3 Comments
7Apr/093

Error 1307 creating stored procedure

Trying to create a stored procedure, and getting a cryptic error like this?

ERROR 1307 (HY000): Failed to CREATE PROCEDURE <procName>

Try this simple diagnostic query first:

SELECT
  IF(
    COUNT(*) XOR (CAST(VERSION() AS decimal(2, 1)) >= 5.1),
    'Wrong mysql.proc table version. Did you forget to run mysql_upgrade?',
    'The mysql.proc table looks ok. Keep hunting.'
  ) AS troubleshooting
FROM
  information_schema.columns
WHERE
  table_schema = 'mysql'
  AND table_name = 'proc'
  AND column_name LIKE 'body_utf8';
Filed under: MySQL FAQ 3 Comments