MySQL database import error #1064 - mysql

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

Related

#1064 - MySQL Error

CREATE TABLE `phpbb_acl_groups` (
`group_id` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',
`forum_id` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',
`auth_option_id` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',
`auth_role_id` MEDIUMINT( 8 ) UNSIGNED NOT NULL DEFAULT '0',
`auth_setting` TINYINT( 2 ) NOT NULL DEFAULT '0',
KEY `group_id` ( `group_id` ) ,
KEY `auth_opt_id` ( `auth_option_id` ) ,
KEY `auth_role_id` ( `auth_role_id` )
) TYPE = MYISAM ;
MySQL meldet: 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' at line 10
TYPE = MYISAM ; has been depreciated and you should be using engine instead
engine = MYISAM

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

Wordpress PhpMyAdmin import db error

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;

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.

Right syntax for creating a foreign key

I use MySql 5.5.8 and I can't find out how should I write which field need to be a foreign key refererece. For example:
CREATE TABLE IF NOT EXISTS `answers` (
`id` int( 11 ) NOT NULL AUTO_INCREMENT ,
`answer` text COLLATE utf8_polish_ci NOT NULL ,
`user` tinyint( 4 ) DEFAULT NULL ,
`created` timestamp NULL DEFAULT CURRENT_TIMESTAMP ,
`html_template_id` int( 11 ) NOT NULL ,
PRIMARY KEY ( `id` ) ,
CONSTRAINT html_template_id FOREIGN KEY `html_template_id` REFERENCES `html_templates` ( `id` )
) ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_polish_ci AUTO_INCREMENT =1;
And I get an error message:
#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 'REFERENCES `html_templates`(`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=' at line 10
use
CONSTRAINT html_template_id FOREIGN KEY (`html_template_id`) REFERENCES `html_templates` ( `id` )
i.e. the foreign key field should be in brackets