Webmail fails to load: Integrity constraint violation: Duplicate entry '0'

Created:

2016-11-16 12:56:04 UTC

Modified:

2017-08-16 17:40:06 UTC

0

Was this article helpful?


Have more questions?

Submit a request

Webmail fails to load: Integrity constraint violation: Duplicate entry '0'

Applicable to:

  • Plesk 11.x for Linux

Symptoms

Error message on login to Horde webmail:

    A fatal error has occurred
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'

Cause

The issue is caused by the missing "auto_increment" value of "share_id" column in "mnemo_shares" or/and "turba_shares" tables of "horde" database.

Resolution

  1. Enable MySQL logging:

    Add the following to your /etc/my.cnf in the [mysqld] section and restart the mysql server after making those changes:

        log=/tmp/mysqld.log
  2. Find the SQL query that leads to error:

    66460 Query     SELECT 1
    66460 Query INSERT INTO mnemo_shares (share_name, share_parents, share_owner, attribute_name, perm_creator, perm_default, perm_guest, share_flags) VALUES ('!#224334PTAMnmSarow1', NULL, 'test@domain.tld', 'Notepad of test@domain.tld', 0, 0, 0, 0)
  3. Check the mnemo_shares table. The share_id column should have "auto_increment" parameter:

        mysql> desc horde.mnemo_shares;
    +----------------+--------------+------+-----+---------+-------+
    | Field | Type | Null | Key | Default | Extra |
    +----------------+--------------+------+-----+---------+-------+
    | share_id | int(11) | NO | PRI | NULL | |

    If there is no "auto_increment" parameter, it is necessary to modify "mnemo_shares" table as below.

  4. Create backup of horde database:

    ~# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin horde >horde.dump
  5. Login to Horde database and add "auto_increment" parameter for "share_id" column:

    ~# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin horde

    mysql> ALTER TABLE horde.mnemo_shares MODIFY share_id INT(11)AUTO_INCREMENT;
    Query OK, 1 row affected (0.11 sec)
    Records: 1 Duplicates: 0 Warnings: 0

    mysql> desc mnemo_shares;
    +----------------+--------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +----------------+--------------+------+-----+---------+----------------+
    | share_id | int(11) | NO | PRI | NULL | auto_increment |
    +----------------+--------------+------+-----+---------+----------------+

    Please do not forget to delete MySQL logging in /etc/my.cnf and restart Mysql server.

  6. If the error still persists after that, please do the following:

6.1. Backup data of horde database as below:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin horde --no-create-info > horde_data.txt

6.2. In attachment you will find the Tables Structure of Horde database , restore this dump as below:

# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin horde < horde_structure.txt

6.3. Restore data of your horde database:

    # MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin horde < horde_data.txt

Horde_Structure

Attachments:

Have more questions? Submit a request
Please sign in to leave a comment.