MySQL Dump Not Importing - mysql

I did a SQL Dump from my MySQL [version 5.6.12] a few days ago now I am trying to import back to the same DB.
The line
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
is not working, it throws a
#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 ') ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1' error.
I have tripple checked the syntax, and even copped and pasted from one of the other tables that successfully import.
not sure what could be wrong.
here is the full SQL: http://pastebin.com/hrBKv7Su.
NOTE: I know there are simlar posts none have helped so far.

When faced with a 1064 error that points to a specific location, look to the character or word right before it. There, you'll find an errant trailing comma in this case.
CREATE TABLE IF NOT EXISTS `item` (
`id` mediumint(8) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(11) NOT NULL,
`string` VARCHAR(30) NOT NULL,
`price` DECIMAL(9,2) NOT NULL,
`note` VARCHAR(500) DEFAULT NULL,
`categoryId` SMALLINT(5) UNSIGNED NOT NULL,
`printerId` tinyint(3) NULL DEFAULT NULL,
`hidden` tinyint(1) NOT NULL DEFAULT '0',
`inStock` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `categoryId` (`categoryId`,`printerId`),
KEY `printerId` (`printerId`),
/* -------------------------^^^ remove that comma */
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Related

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB

CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` double(11) NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use
near ') NOT NULL, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT
CHARSET=latin1 AUTO_INCRE' at line 5
try using float without the number of showing digit
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` double NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
and for price could be you need a fixed decimal length so you should use decimal
CREATE TABLE IF NOT EXISTS `tbl_product` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`image` varchar(255) NOT NULL,
`price` decimal(10,2) NOT NULL,
PRIMARY KEY (id))
ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
You're missing a value in your double specifier:
`price` double(11) NOT NULL
It needs both the total digits and the digits following the decimal. Something like:
`price` double(11,2) NOT NULL
Though for currency values you may be better off using decimal instead:
`price` decimal(11,2) NOT NULL
As this uses a more fixed precision. Using a double may result in unexpected calculation results from how floating point arithmetic works.

Why is sql not letting me create this table?

I'm trying to migrate a db
from: MySQL Distrib 5.5.60-MariaDB, for Linux (x86_64)
to: MySQL 5.5.4, UNIX
I tried importing the db as a zip package and it started throwing errors so now I'm trying to re-create each table one at a time on phpMyAdmin.
The query below is throwing a #1064 Syntax error, and I'm having trouble figuring out the issue.
MySQL Said:
#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 '(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
`st' at line 6
I'm looking at line 6, trying to find any reserved words, missing data, typos, and or obsolete commands but no luck.
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP,
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
I could use some help.
Thanks in advance.
CURRENT_TIMESTAMP is not good
Try this:
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
This works in SQL Fiddle:
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
i.e., remove the precision (the (2)) from the definition of the date_added column.
TIMESTAMP(2) is valid syntax, but not in combination with the DEFAULT CURRENT_TIMESTAMP nor ON UPDATE CURRENT_TIMESTAMP auto-initializers.

SQL query error #1064 without any obvious error

I'm scratching my head over this error. I'm trying to import a sql file through phpmyadmin and it comes up with this errors one after another and I cannot sea anything wrong with it. Can someone please analyse the lines below and let me know if they see any errors?
Thank you
--
-- Table structure for table `jos_address_members`
--
CREATE TABLE IF NOT EXISTS `jos_address_members` (
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`adid` int(10) unsigned NOT NULL DEFAULT '0',
`publish` tinyint(4) NOT NULL DEFAULT '1',
`ordering` tinyint(3) unsigned NOT NULL DEFAULT '9',
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
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 ') ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' at line 12
Remove the comma after DEFAULT '9'
CREATE TABLE IF NOT EXISTS `jos_address_members` (
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`adid` int(10) unsigned NOT NULL DEFAULT '0',
`publish` tinyint(4) NOT NULL DEFAULT '1',
`ordering` tinyint(3) unsigned NOT NULL DEFAULT '9'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

the right syntax to use near 'PARTITIONS 101 */ AUTO_INCREMENT=1' at line 19

I am trying to import a large database to my local server with the help of Bigdump script (www.ozerov.de/bigdump/), but I get this error:
Query:
CREATE TABLE IF NOT EXISTS `email_addon_rbp_hard_bounces` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`log_id` int(11) NOT NULL DEFAULT '0',
`from` varchar(255) DEFAULT NULL,
`rcpt` varchar(255) DEFAULT NULL,
`status` varchar(255) DEFAULT NULL,
`message` varchar(455) DEFAULT NULL,
`ip` varchar(45) DEFAULT NULL,
`job_id` varchar(255) DEFAULT NULL,
`date` int(11) NOT NULL DEFAULT '0',
`cat_pmta` varchar(45) DEFAULT NULL,
`group` varchar(255) DEFAULT NULL,
`pattern` varchar(255) DEFAULT NULL,
PRIMARY KEY (`uid`,`log_id`),
KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
PARTITIONS 101 */ AUTO_INCREMENT=1
ERROR:
MySQL: 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 'PARTITIONS 101 */ AUTO_INCREMENT=1' at line 19
What do I do to get past it and import the full db?
I was having the same error. I just searched for all "PARTITIONS 101 /" entries and deleted all the line beginning in /, ending at the */, just before the semicolon.
Do not delete the semicolon.

MYSQL Table Error - 1064

Trying to create the following table:
CREATE TABLE login (
IdUser int(11) NOT NULL AUTO_INCREMENT,
username varchar(45) CHARACTER SET latin1 NOT NULL,
pass varchar(45) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (IdUser),
ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$);
Doesn't seem to work properly. The error I'm getting in MYSQL is:
#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 '=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$' at line 6
Bracket in the wrong spot:
PRIMARY KEY (IdUser),
ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8$$);
^----
should be
PRIMARY KEY (IdUser) <--note removed comma
) ENGINE=MyIsam etc...
^---
You're treating those table options as they were fields, by placing them WITHIN the () field definition block.
In my case some of the sql is working but mostly not working after changing Type=ENGINE.
CREATE TABLE `p4_acl_page` (
`id` int(2) NOT NULL auto_increment,
`label` varchar(80) default NULL,
`lastupdate` timestamp(14) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyIsam;