title: MySQL Workbench | ERROR: Error 1280: Incorrect index name
body: <p>I've got some problems using foreign keys in my database using InnoDB tables. I'm using MySQL Workbench for designing my ER models and have a Zend Server (OS X) for development with MySQL 5.1.54. Everything works fine without any error.</p>
  
  <p>When deploying this database to my live server it fails. It is a Debian installation with MySQL 5.1.58-1~dotdeb.1-log. I can't understand why these two systems work so different.</p>
  
  <blockquote>
    <p>ERROR: Error 1280: Incorrect index name 'fk_accounts_countries_idcountry'</p>
  </blockquote>
  
  <pre><code>DROP TABLE IF EXISTS `countries` ;
  
  SHOW WARNINGS;
  CREATE  TABLE IF NOT EXISTS `countries` (
    `idcountry` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT ,
    `name` CHAR(50) NOT NULL ,
    `prefix` CHAR(2) NULL DEFAULT NULL ,
    `tld` CHAR(4) NULL DEFAULT NULL ,
    PRIMARY KEY (`idcountry`) )
  ENGINE = InnoDB
  AUTO_INCREMENT = 270
  DEFAULT CHARACTER SET = utf8
  COLLATE = utf8_general_ci;
  
  SHOW WARNINGS;
  
  -- -----------------------------------------------------
  -- Table `accounts`
  -- -----------------------------------------------------
  DROP TABLE IF EXISTS `accounts` ;
  
  SHOW WARNINGS;
  CREATE  TABLE IF NOT EXISTS `accounts` (
    `idaccount` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
    `countries_idcountry` SMALLINT UNSIGNED NOT NULL ,
    `fk_account` INT UNSIGNED NOT NULL ,
    `fk_country` INT UNSIGNED NOT NULL ,
    `username` CHAR(30) NOT NULL ,
    `password` CHAR(32) NOT NULL ,
    `mail` CHAR(50) NOT NULL ,
    `address` CHAR(50) NULL ,
    `city` CHAR(50) NOT NULL ,
    `company` CHAR(50) NULL ,
    `phone` CHAR(25) NULL ,
    `regdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
    `ratedate` TIMESTAMP NULL ,
    `lastlogin` TIMESTAMP NULL ,
    `activated` TINYINT(1)  NULL DEFAULT 0 ,
    `activation` CHAR(32) NULL ,
    PRIMARY KEY (`idaccount`) ,
    CONSTRAINT `fk_accounts_countries_idcountry`
      FOREIGN KEY (`countries_idcountry` )
      REFERENCES `countries` (`idcountry` )
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  
  SHOW WARNINGS;
  CREATE INDEX `fk_accounts_countries_idcountry` ON `accounts` (`countries_idcountry`ASC);
  
  SHOW WARNINGS;
  </code></pre>