ERROR 1005 (HY000): Can't create table 'phact_greenland.cache' (errno: 121) I get an error when I try to create a table:


  ERROR 1005 (HY000): Can't create table 'phact_greenland.cache' (errno: 121) 


CREATE TABLE IF NOT EXISTS `cache` 
(   
    `cid` varchar(255) NOT NULL DEFAULT '' 
        COMMENT 'Primary Key: Unique cache ID.'
    , `data` longblob 
        COMMENT 'A collection of data to cache.' 
    , `expire` int(11) NOT NULL DEFAULT '0' 
        COMMENT 'A Unix timestamp indicating when the cache entry 
                should expire, or 0 for never.'  
    , `created` int(11) NOT NULL DEFAULT '0' 
        COMMENT 'A Unix timestamp indicating when the cache entry was created.'  
    , `serialized` smallint(6) NOT NULL DEFAULT '0' 
        COMMENT 'A flag to indicate whether content is serialized (1) or not (0).' 
    , PRIMARY KEY (`cid`) 
    , KEY `expire` (`expire`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 
    COMMENT='Generic cache table for caching things not separated out...';


How do i solve it ?
You get Error 121 when you try to create a table that contains a constraint with the same name as a constraint defined elsewhere in your database. You can avoid this issue by naming the constraints yourself in the creation script. More information can be found below:

InnoDb Error Codes

http://dev.mysql.com/doc/refman/5.5/en/innodb-error-codes.html

Create Table Statement

http://dev.mysql.com/doc/refman/5.5/en/create-table.html

I hope this helps you.