Wordpress PhpMyAdmin import db error - mysql

Im trying to move my wordpress site over to another hosting. I have exported the db and I am re-importing it onto the hosting. The database does have a different name but I have updated the file.
Here is the error I receive when trying to import it:
Error
SQL query:
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
`comment_id` bigint( 20 ) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar( 255 ) DEFAULT NULL ,
`meta_value` longtext,
PRIMARY KEY ( `meta_id` ) ,
KEY `comment_id` ( `comment_id` ) ,
KEY `meta_key` ( `meta_key` )
) TYPE = MYISAM AUTO_INCREMENT =17;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM AUTO_INCREMENT=17' at line 9
I had a look on here and a lot of people said it was because Add CREATE PROCEDURE / FUNCTION / EVENT statement needed ticking, but I have done this.

As documented under CREATE TABLE Syntax:
Note
The older TYPE option was synonymous with ENGINE. TYPE was deprecated in MySQL 4.0 and removed in MySQL 5.5. When upgrading to MySQL 5.5 or later, you must convert existing applications that rely on TYPE to use ENGINE instead.
Therefore, you want:
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint( 20 ) unsigned NOT NULL AUTO_INCREMENT ,
`comment_id` bigint( 20 ) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar( 255 ) DEFAULT NULL ,
`meta_value` longtext,
PRIMARY KEY ( `meta_id` ) ,
KEY `comment_id` ( `comment_id` ) ,
KEY `meta_key` ( `meta_key` )
) ENGINE = MYISAM AUTO_INCREMENT =17;

Related

Importing WordPress Database - #1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key

I'm trying to move a WordPress database from Plesk to cPanel using phpMyAdmin but I get the following error when importing:
SQL query:
Table structure for table `wp_commentmeta`
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`comment_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
`meta_key` VARCHAR( 255 ) DEFAULT NULL ,
`meta_value` LONGTEXT
) ENGINE = MYISAM AUTO_INCREMENT =236 DEFAULT CHARSET = utf8;
MySQL said: Documentation
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
I exported the database using the quick option as I normally do then just did a normal import.
The relevant part of the sql export is:
--
-- Table structure for table `wp_commentmeta`
--
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext
) ENGINE=MyISAM AUTO_INCREMENT=236 DEFAULT CHARSET=utf8;
So I tried a solution mentioned on Google
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL PRIMARY KEY auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext
) ENGINE=MyISAM AUTO_INCREMENT=236 DEFAULT CHARSET=utf8;
And this time I got this error:
SQL query:
CREATE TABLE IF NOT EXISTS `wp_comments` (
`comment_ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`comment_post_ID` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
`comment_author` TINYTEXT NOT NULL ,
`comment_author_email` VARCHAR( 100 ) NOT NULL DEFAULT '',
`comment_author_url` VARCHAR( 200 ) NOT NULL DEFAULT '',
`comment_author_IP` VARCHAR( 100 ) NOT NULL DEFAULT '',
`comment_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_date_gmt` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment_content` TEXT NOT NULL ,
`comment_karma` INT( 11 ) NOT NULL DEFAULT '0',
`comment_approved` VARCHAR( 20 ) NOT NULL DEFAULT '1',
`comment_agent` VARCHAR( 255 ) NOT NULL DEFAULT '',
`comment_type` VARCHAR( 20 ) NOT NULL DEFAULT '',
`comment_parent` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
`user_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0'
) ENGINE = MYISAM AUTO_INCREMENT =226 DEFAULT CHARSET = utf8;
MySQL said: Documentation
#1075 - Incorrect table definition; there can be only one auto column and it must be defined as a key
The CREATE section for wp_comments is as follows.
DROP TABLE IF EXISTS `wp_comments`;
CREATE TABLE IF NOT EXISTS `wp_comments` (
`comment_ID` bigint(20) unsigned NOT NULL auto_increment,
`comment_post_ID` bigint(20) unsigned NOT NULL default '0',
`comment_author` tinytext NOT NULL,
`comment_author_email` varchar(100) NOT NULL default '',
`comment_author_url` varchar(200) NOT NULL default '',
`comment_author_IP` varchar(100) NOT NULL default '',
`comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
`comment_content` text NOT NULL,
`comment_karma` int(11) NOT NULL default '0',
`comment_approved` varchar(20) NOT NULL default '1',
`comment_agent` varchar(255) NOT NULL default '',
`comment_type` varchar(20) NOT NULL default '',
`comment_parent` bigint(20) unsigned NOT NULL default '0',
`user_id` bigint(20) unsigned NOT NULL default '0'
) ENGINE=MyISAM AUTO_INCREMENT=226 DEFAULT CHARSET=utf8;
At the bottom of the dump is the following auto_increment information.
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `wp_commentmeta`
--
ALTER TABLE `wp_commentmeta`
AUTO_INCREMENT=236;
--
-- AUTO_INCREMENT for table `wp_comments`
--
ALTER TABLE `wp_comments`
AUTO_INCREMENT=226;
--
-- AUTO_INCREMENT for table `wp_event_list`
--
ALTER TABLE `wp_event_list`
AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT for table `wp_layerslider`
--
ALTER TABLE `wp_layerslider`
AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `wp_options`
--
ALTER TABLE `wp_options`
AUTO_INCREMENT=497473;
--
-- AUTO_INCREMENT for table `wp_postmeta`
--
ALTER TABLE `wp_postmeta`
AUTO_INCREMENT=18312;
--
-- AUTO_INCREMENT for table `wp_posts`
--
ALTER TABLE `wp_posts`
AUTO_INCREMENT=2083;
--
-- AUTO_INCREMENT for table `wp_terms`
--
ALTER TABLE `wp_terms`
AUTO_INCREMENT=136;
--
-- AUTO_INCREMENT for table `wp_term_taxonomy`
--
ALTER TABLE `wp_term_taxonomy`
AUTO_INCREMENT=137;
--
-- AUTO_INCREMENT for table `wp_usermeta`
--
ALTER TABLE `wp_usermeta`
AUTO_INCREMENT=1527;
--
-- AUTO_INCREMENT for table `wp_users`
--
ALTER TABLE `wp_users`
AUTO_INCREMENT=43;
--
-- AUTO_INCREMENT for table `wp_woocommerce_attribute_taxonomies`
--
ALTER TABLE `wp_woocommerce_attribute_taxonomies`
AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `wp_woocommerce_order_itemmeta`
--
ALTER TABLE `wp_woocommerce_order_itemmeta`
AUTO_INCREMENT=1869;
--
-- AUTO_INCREMENT for table `wp_woocommerce_order_items`
--
ALTER TABLE `wp_woocommerce_order_items`
AUTO_INCREMENT=294;
--
-- AUTO_INCREMENT for table `wp_woocommerce_tax_rates`
--
ALTER TABLE `wp_woocommerce_tax_rates`
AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT for table `wp_woocommerce_termmeta`
--
ALTER TABLE `wp_woocommerce_termmeta`
AUTO_INCREMENT=116;
And this is where I'm really stuck as I've rapidly and suddenly reached the limit of my knowledge and don't want to make matters worse. I'm used to seeing the info in the alter table section within the create and don't know id I should be copying it into the create sections or what.
Can someone please provide some hints as to why this is occurring.
Thanks.
For each Wordpress table, add its key in this way (see the penultimate line):
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext,
key (meta_id) -- add this line (remember to add the comma in the previous line)
) ENGINE=MyISAM AUTO_INCREMENT=236 DEFAULT CHARSET=utf8;
Wordpress tables:
wp_commentmeta
wp_comments
wp_links
wp_options
wp_postmeta
wp_posts
wp_terms
wp_term_relationships
wp_term_taxonomy
wp_usermeta
wp_users
Possible that you are using two different versions of phpmyadmin, one in plesk, the other one in your cpanel system?
You could try 'Adminer', which is a powerful phpmyadmin alternative and it is based on only one single file!
Download it from here: http://www.adminer.org/en/
Copy adminer.php to the server where you want to get the export from and to the one where you want to import the sql data.
Go to your website/adminer.php and login to your db with the credentials you have. The Export and import is similar to phpmyadmin but the advantage is that you are using one common version of the adminer software which makes sure that import and export is gonna be run fine.
I have the same problem when I export from another phpMyAdmin, the file mysql export does not include primary key in there, then when exporting I choosed method "Custom - display all possible options", then I checked "IF NOT EXISTS (less efficient as indexes will be generated during table creation)". And then the exported file included primary key in the file. And my problem is solved. I hope this help you.
This problem is documented by phpMyAdmin (PMA) and "fixed" by essentially saying that you can't use the current version with MySQL 5.0.
http://sourceforge.net/p/phpmyadmin/bugs/4437/
http://sourceforge.net/p/phpmyadmin/bugs/4261/
Table export with auto_increment, primary key creates invalid statements > Problems due to missing enforcement of the minimum supported MySQL version
Found out my server is running PMA 4.3 with MYSQL 5.0.95 whereas my local is MYSQL 5.5. I don't know why this is a problem now, as older PMA would import/export beautifully as mysqldump, I guess they changed and simplified the syntax for performances reasons which is legit.
If you're like me, you exported your tables from MySQL 5.5 (hosting server) and tried to import into MySQL 5.6 (XAMPP on Mac) and you got the dreaded 1075 error. After searching on the Internet for hours you found out it has something to do with the Auto-increment and Primary key. Not being a database programmer, this information (provided in links by liquified, above) does not help solve the problem as you're basically told: "Hey, don't do that". Well mr. PMA bug, it's already done, so how do I fix it?
Here's what worked for me:
The SQL you exported has a bunch of statements near the bottom to "ALTER" all the tables you created at top. All you need to do is copy into the CREATE statement above.
So, at the bottom, your ALTER wp_commentmeta looks like this:
ALTER TABLE `wp_commentmeta`
ADD PRIMARY KEY (`meta_id`),
ADD KEY `comment_id` (`comment_id`),
ADD KEY `meta_key` (`meta_key`);
And at the top, the CREATE looks like this:
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext
) TYPE=MyISAM AUTO_INCREMENT=67;
The solution is to remove the ALTER at bottom and put those statements into the CREATE, like this (adding the comma after the 'longtext'):
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`)
) TYPE=MyISAM AUTO_INCREMENT=67;
Now, if you use this, you'll get a 1064 error for bad syntax. Can a guy get a break? You still need to change the MyISAM stuff for this new version:
TYPE=MyISAM AUTO_INCREMENT=67;
change to
ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=67;
In the end your final CREATE declaration will look like this and you won't need any ALTER table statements at the bottom of your SQL:
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL auto_increment,
`comment_id` bigint(20) unsigned NOT NULL default '0',
`meta_key` varchar(255) default NULL,
`meta_value` longtext,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=50 ;
Yes, you have to manually edit your SQL if you plan on importing it into the new DB. If you have a lot of tables and/or websites affected by this 'bug', it will take some time, so grab a coffee, whatever works, and fix it and move on with your life.
Now, if you still get errors, check your syntax, make sure to remove 'ADD' when you copy from the ALTER table. Remove ';' and use commas correctly. If you managed to import part of the DB, a few tables, but got snagged on syntax, DUMP all tables and try your import again once you've made the fix. I encountered a 1062: duplicate primary key because I managed to import some tables and others failed. When I tried to import again, the primary key was already set for the table.
All this headache because of performance 'enhancements' in new PMA/MySQL. Humbug!

MySQL database import error #1064

I have a SQL database that I want to import using phplyadmin but I am getting this error.
CREATE TABLE `wp_commentmeta` (
`meta_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`comment_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0',
`meta_key` VARCHAR( 255 ) DEFAULT NULL ,
`meta_value` LONGTEXT,
PRIMARY KEY ( `meta_id` ) ,
KEY `comment_id` ( `comment_id` ) ,
KEY `meta_key` ( `meta_key` ( 191 ) )
) ENGINE = Aria AUTO_INCREMENT =3843 DEFAULT CHARSET = utf8
PAGE_CHECKSUM =1 DELAY_KEY_WRITE =1 TRANSACTIONAL =1;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'PAGE_CHECKSUM=1 DELAY_KEY_WRITE=1 TRANSACTIONAL=1' at line 9
If you are not using MariaDB, change ENGINE=Aria to ENGINE=MyISAM(or ENGINE=InnoDB) and remove PAGE_CHECKSUM=1 and TRANSACTIONAL =1;
Find an example here

Import 5.5 sql export to 5.0 sql?

I have made a website locally on my mac, using MAMP. Now i need to upload the site to the internet. So i upload the files via FTP, create a database using the Cpanel, and now i want to import the database. But i keep getting "#1064 - You have an error in your SQL syntax;" I just found out that the sql version on MAMP is: 5.5.33 and the version my web provider uses is 5.0.95 could this be the problem?
how do i solve this?
This is the code that it complains about:
CREATE TABLE `wp_commentmeta` (
\ `meta_id` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT , \ `comment_id` BIGINT( 20 ) UNSIGNED NOT NULL DEFAULT '0' , \ `meta_key` VARCHAR( 255 ) DEFAULT NULL , \ `meta_value` LONGTEXT , \ PRIMARY KEY ( `meta_id` ) , \ KEY `comment_id` ( `comment_id` ) , \ KEY `meta_key` ( `meta_key` ) \
) ENGINE = INNODB DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;

mysql syntax error: 'USING BTREE ) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 AUTOINCREMENT='

Im getting this error:
CREATE TABLE `pdc5l_usergroups` (
`id` int( 10 ) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Clave primaria',
`parent_id` int( 10 ) unsigned NOT NULL DEFAULT '0' COMMENT 'ID Lista de referencia adyacente',
`lft` int( 11 ) NOT NULL DEFAULT '0' COMMENT 'Anidadas conjunto lft.',
`rgt` int( 11 ) NOT NULL DEFAULT '0' COMMENT 'Anidadas conjunto rgt.',
`title` varchar( 100 ) NOT NULL DEFAULT '',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `idx_usergroup_parent_title_lookup` ( `parent_id` , `title` ) ,
KEY `idx_usergroup_title_lookup` ( `title` ) ,
KEY `idx_usergroup_adjacency_lookup` ( `parent_id` ) ,
KEY `idx_usergroup_nested_set_lookup` ( `lft` , `rgt` ) USING BTREE
) ENGINE = MYISAM AUTO_INCREMENT =9 DEFAULT CHARSET = utf8AUTOINCREMENT =9;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 AUTOINCREMENT=' at line 11
I have tried these:
) ENGINE = MYISAM AUTO_INCREMENT =9 DEFAULT CHARSET = utf8 AUTO_INCREMENT =9;
) ENGINE = MYISAM AUTOINCREMENT =9 DEFAULT CHARSET = utf8 AUTOINCREMENT =9;
) ENGINE = MYISAM AUTOINCREMENT =9 DEFAULT CHARSET = utf8 AUTO_INCREMENT =9;
but I still get the error.
phpmyadmin says this: MySQL client version: 4.1.22
This is a mysql version problem. You can see the issue in that bug:
http://bugs.mysql.com/bug.php?id=25162
Before MySQL 5.0.60, this option can be given only before the ON
tbl_name clause. Use of the option in this position is deprecated as
of 5.0.60 and support for it there will be removed in a future MySQL
release. If an index_type option is given in both the earlier and
later positions, the final option applies.
TYPE type_name is recognized as a synonym for USING type_name.
However, USING is the preferred form.
For more details see here: http://www.dbforums.com/mysql/1617755-using-btree.html

MYSQL Error #1064 Error in SQL Syntax

I keep getting this error:
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=13' at line 11
with this with this query:
SQL query:
CREATE TABLE IF NOT EXISTS `jml_usergroups` (
`id` int( 10 ) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
`parent_id` int( 10 ) unsigned NOT NULL DEFAULT '0' COMMENT 'Adjacency List Reference Id',
`lft` int( 11 ) NOT NULL DEFAULT '0' COMMENT 'Nested set lft.',
`rgt` int( 11 ) NOT NULL DEFAULT '0' COMMENT 'Nested set rgt.',
`title` varchar( 100 ) NOT NULL DEFAULT '',
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `idx_usergroup_parent_title_lookup` ( `parent_id` , `title` ) ,
KEY `idx_usergroup_title_lookup` ( `title` ) ,
KEY `idx_usergroup_adjacency_lookup` ( `parent_id` ) ,
KEY `idx_usergroup_nested_set_lookup` ( `lft` , `rgt` ) USING BTREE
) ENGINE = MYISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT =13;
Any idea what the problem is? these errors are like the thorns on a rose
The syntax is ok, your problem is probably that you're trying to run it on a MySQL version earlier than 5.1, which does not have USING BTREE.