MySQL 1062 – Duplicate entry ‘0’ for key ‘PRIMARY’

You need to specify the primary key as auto-increment CREATE TABLE `momento_distribution` ( `momento_id` INT(11) NOT NULL AUTO_INCREMENT, `momento_idmember` INT(11) NOT NULL, `created_at` DATETIME DEFAULT NULL, `updated_at` DATETIME DEFAULT NULL, `unread` TINYINT(1) DEFAULT ‘1’, `accepted` VARCHAR(10) NOT NULL DEFAULT ‘pending’, `ext_member` VARCHAR(255) DEFAULT NULL, PRIMARY KEY (`momento_id`, `momento_idmember`), KEY `momento_distribution_FI_2` (`momento_idmember`), KEY `accepted` (`accepted`, `ext_member`) … Read more

MySQL database with unique fields ignored ending spaces

The problem is that MySQL ignores trailing whitespace when doing string comparison. See http://dev.mysql.com/doc/refman/5.7/en/char.html All MySQL collations are of type PADSPACE. This means that all CHAR, VARCHAR, and TEXT values in MySQL are compared without regard to any trailing spaces. … For those cases where trailing pad characters are stripped or comparisons ignore them, if … Read more

Are table names in MySQL case sensitive?

In general: Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix. In MySQL, databases correspond to directories within the data directory. Each table within a database corresponds to at least one file within the database directory. Consequently, the case sensitivity of the underlying operating system plays … Read more