Answers.Body: <p>I had a similar issue upgrading from 4.5.8 to 4.6.4, what worked for me was to manually remove the civicrm_mailing_abtest table from the database. 
  Restore your database backup before the upgrade and login to mysql</p>
  
  <p><strong>Update:</strong>
  To restore your backup database:</p>
  
  <pre><code>mysql -u root -p // login to mysql
  
  drop database civicrm; // delete the current database, the one is failing to upgrade
  
  create database civicrm; // create a new empty database
  
  quit // logout from mysql
  </code></pre>
  
  <p><strong>Restoring the database backup</strong></p>
  
  <pre><code>mysql -u root -p -h localhost civicrm &lt; /path/to/your/database/backup/civicrm-database-backup.sql // write the backup to the new empty database
  </code></pre>
  
  <p>Replace "/path/to/your/database/backup" with your backup directory and "civicrm-database-backup.sql" with the name of your Civicrm backup SQL file.</p>
  
  <p><strong>Check for the existing civicrm_mailing_abtest table</strong></p>
  
  <pre><code>mysql -u root -p
  
  use civicrm; // replace civicrm with the name of your database
  
  show tables; // it will give you a list with the civicrm database tables
  </code></pre>
  
  <p>If the civicrm_mailing_abtest is listed in the output, remove it, as it shouldn't be there, the A/B Test mailing was introduced in CiviCRM 4.6</p>
  
  <pre><code>drop table civicrm_mailing_abtest; // this will remove the table
  </code></pre>
  
  <p>After that proceed with the upgrade again.</p>
  
  <p>Hope this helps</p>
  
  <p><strong>Update 2:</strong>
  If you have permission errors after the restore, you will need to grant permission to the civicrm mysql user</p>
  
  <pre><code>mysql -u root -p
  
  grant all on civicrm.* to 'username' identified by 'password';
  
  flush privileges;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-03T15:23:48.547Z
Answers.Text: This answer should really include a `DROP DATABASE civicrm` and `CREATE DATABASE civicrm` before restoring the database backup.  Restoring a database backup only overwrites tables that existed in the backup; newly-created tables are NOT written over.  That's what leads to this problem in the first place!
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-03T16:33:46.357Z
Answers.Text: Sorry about that, I have updated the answer with restore instructions
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-06T21:36:48.347Z
Answers.Text: Run this in mysql: SHOW ENGINE INNODB STATUS\G, there should be an Foreign Key errors section in the output. Paste the result here.
Answers.UserDisplayName: Andrei
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-08-02T11:49:48.660Z
Answers.LastActivityDate: 2015-08-03T16:59:13.177Z
Answers.LastEditDate: 2015-08-03T16:59:13.177Z
Answers.UserDisplayName: Andrei
Body: <p>I have a good installation of CiviCRM on Wordpress, but now i want to upgrade to version 4.6.5 and when ik upgrade, the upgrade stops at 4.6.alpha7</p>
  
  <p>I am trying for 4 hours to get an solution So i have tried to export the structure and data end make a new database  with the original structure imports. But nothing will work..</p>
  
  <p><strong>EDIT:</strong>
  I have checked all the tables with a compare program,
  Left= Current version 4.5.2 / working civicrm (Backup / before Upgrade)
  Right= Original civicrm.mysql version 4.5.2</p>
  
  <p><strong>RESULT:</strong>
  Only tables civicrm_value_**** are not in the right (original) version.</p>
  
  <p><strong>EDIT 2:</strong>
  I can upgrade to version 4.5.8 without problems. If i want to upgrade then to 4.6.6 It will also stop at 4.6.alpha7 (error below)</p>
  
  <p>I have also checked if there is a table civicrm_mailing_abtest but this table does not exist.</p>
  
  <p>I hope someone can help me to solve this problem.</p>
  
  <p>Thanks a lot. It is a fantastic plugin!! ( CiviCRM )</p>
  
  <p>With kind regards,</p>
  
  <p>Mark</p>
  
  <p>This is the error:</p>
  
  <pre><code>[Error: Upgrade DB to 4.6.alpha7]
  Fout Veld   fout waarde
  Type    DB_Error
  Code    -1
  Message DB Error: unknown error
  Mode    16
  UserInfo    ALTER TABLE civicrm_mailing_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1215 ** Cannot add foreign key constraint]
  DebugInfo   ALTER TABLE civicrm_mailing_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1215 ** Cannot add foreign key constraint]
  PEAR_Exception: DB Error: unknown error in unknown on line unknown
  - DB_Error: DB Error: unknown error in unknown on line unknown
  Exception trace
  </code></pre>
  
Tags: <wordpress><upgrade>
Title: Upgrade Wordpress CiviCRM Version from 4.5.2 to 4.6.5
ThreadText: # Upgrade Wordpress CiviCRM Version from 4.5.2 to 4.6.5
  
  (Asked by: username_0 on 2015-08-01)
  
  I have a good installation of CiviCRM on Wordpress, but now i want to upgrade to version 4.6.5 and when ik upgrade, the upgrade stops at 4.6.alpha7
  I am trying for 4 hours to get an solution So i have tried to export the structure and data end make a new database  with the original structure imports. But nothing will work..
  EDIT:
  I have checked all the tables with a compare program,
  Left= Current version 4.5.2 / working civicrm (Backup / before Upgrade)
  Right= Original civicrm.mysql version 4.5.2
  RESULT:
  Only tables civicrm_value_**** are not in the right (original) version.
  EDIT 2:
  I can upgrade to version 4.5.8 without problems. If i want to upgrade then to 4.6.6 It will also stop at 4.6.alpha7 (error below)
  I have also checked if there is a table civicrm_mailing_abtest but this table does not exist.
  I hope someone can help me to solve this problem.
  Thanks a lot. It is a fantastic plugin!! ( CiviCRM )
  With kind regards,
  Mark
  This is the error:
  [Error: Upgrade DB to 4.6.alpha7]
  Fout Veld   fout waarde
  Type    DB_Error
  Code    -1
  Message DB Error: unknown error
  Mode    16
  UserInfo    ALTER TABLE civicrm_mailing_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1215 ** Cannot add foreign key constraint]
  DebugInfo   ALTER TABLE civicrm_mailing_abtest ADD COLUMN `created_id` int unsigned COMMENT 'FK to Contact ID', ADD COLUMN `created_date` datetime COMMENT 'When was this item created', ADD COLUMN `testing_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD COLUMN `winner_criteria` varchar(32) COLLATE utf8_unicode_ci DEFAULT NULL, ADD CONSTRAINT FK_civicrm_mailing_abtest_created_id FOREIGN KEY (`created_id`) REFERENCES `civicrm_contact`(`id`) ON DELETE SET NULL [nativecode=1215 ** Cannot add foreign key constraint]
  PEAR_Exception: DB Error: unknown error in unknown on line unknown
  - DB_Error: DB Error: unknown error in unknown on line unknown
  Exception trace
  
  **Tags:** wordpress, upgrade
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2015-08-02. Score: 2
  
  I had a similar issue upgrading from 4.5.8 to 4.6.4, what worked for me was to manually remove the civicrm_mailing_abtest table from the database. 
  Restore your database backup before the upgrade and login to mysql
  Update:
  To restore your backup database:
  mysql -u root -p // login to mysql
  
  drop database civicrm; // delete the current database, the one is failing to upgrade
  
  create database civicrm; // create a new empty database
  
  quit // logout from mysql
  
  Restoring the database backup
  mysql -u root -p -h localhost civicrm < /path/to/your/database/backup/civicrm-database-backup.sql // write the backup to the new empty database
  
  Replace "/path/to/your/database/backup" with your backup directory and "civicrm-database-backup.sql" with the name of your Civicrm backup SQL file.
  Check for the existing civicrm_mailing_abtest table
  mysql -u root -p
  
  use civicrm; // replace civicrm with the name of your database
  
  show tables; // it will give you a list with the civicrm database tables
  
  If the civicrm_mailing_abtest is listed in the output, remove it, as it shouldn't be there, the A/B Test mailing was introduced in CiviCRM 4.6
  drop table civicrm_mailing_abtest; // this will remove the table
  
  After that proceed with the upgrade again.
  Hope this helps
  Update 2:
  If you have permission errors after the restore, you will need to grant permission to the civicrm mysql user
  mysql -u root -p
  
  grant all on civicrm.* to 'username' identified by 'password';
  
  flush privileges;
  
  > **Comments:**
  > **username_2**: This answer should really include a `DROP DATABASE civicrm` and `CREATE DATABASE civicrm` before restoring the database backup.  Restoring a database backup only overwrites tables that existed in the backup; newly-created tables are NOT written over.  That's what leads to this problem in the first place!  
  > **username_1**: Sorry about that, I have updated the answer with restore instructions  
  > **username_1**: Run this in mysql: SHOW ENGINE INNODB STATUS\G, there should be an Foreign Key errors section in the output. Paste the result here.  
  
  ---
  
  