0
votes

I was woring on a project last year, and was exporting and importing fine, but recently I decided to import my sql file and I cannot import due to lots of errors in each table.

I deleted xampp once I stopped working on it, and now decided to download it again, but am stuck on import, here is my full file:

http://pastebin.com/mddVUU1i

My error is the following:

CREATE TABLE company_type ( company_type_id int(11) NOT NULL,
company_type varchar(50) NOT NULL, company_type_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, company_type_enabled varchar(15) NOT NULL DEFAULT 'enabled' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 MySQL said: Documentation

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 '-----------------------------------------

CREATE TABLE company_type ( `comp' at line 1

But when I delete that, I get another error:

CREATE TABLE employees ( employees_id int(11) NOT NULL,
employees_page int(11) NOT NULL, employees_page_type varchar(15) NOT NULL, employees_user int(11) NOT NULL, employees_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, employees_manage varchar(15) NOT NULL DEFAULT 'sent' ) ENGINE=InnoDB DEFAULT CHARSET=latin1 MySQL said: Documentation

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 '-----------------------------------------

------------------------------------' at line 1

How can I fix this? I have ran the sql through checkers online, and it state'sthe sql is fine.

1
Which MariaDB version are you using and which phpMyAdmin version as well? - Isaac Bennetch
Server version: 10.1.19-MariaDB - mariadb.org binary distribution - user4655002
phpmyadmin: 4.5.1 - user4655002
I don't see anything obviously wrong, either. Here are a few ideas to try: Copy and paste the file in to the SQL tab of phpMyAdmin, then see if it flags anything with a syntax error (with a small red circle/box on the left side of the text). Try importing at the command line and see if the problem continues. Try updating your phpMyAdmin to a more recent version; there have been some fixes for MariaDB compatibility since 4.5.1, though I'm not aware of any directly related to what you're seeing here. - Isaac Bennetch

1 Answers

0
votes

Your table creation is wrong, you are misplacing datetime data-type to timestamp values.

Here is your first erroneous table

CREATE TABLE company_type (  company_type_id int(11) NOT NULL,
company_type varchar(50) NOT NULL,  company_type_date datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,  company_type_enabled varchar(15) NOT NULL DEFAULT 'enabled' ) ENGINE=InnoDB DEFAULT CHARSET=latin1

The problem here is datetime NOT NULL DEFAULT CURRENT_TIMESTAMP

You are using datetime datatype to timestamp values.

if you want to use timestamp datatype then do it this way

CREATE TABLE employees (  employees_id int(11) NOT NULL,
employees_page int(11) NOT NULL,  employees_page_type varchar(15) NOT NULL, employees_user int(11) NOT NULL, 
 employees_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,  
employees_manage varchar(15) NOT NULL DEFAULT 'sent' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

if you want to use datetime datatype then do it this way

CREATE TABLE employees1 (  employees_id int(11) NOT NULL,
employees_page int(11) NOT NULL,  employees_page_type varchar(15) NOT NULL, employees_user int(11) NOT NULL, 
 employees_date datetime NOT NULL, 
 employees_manage varchar(15) NOT NULL DEFAULT 'sent' ) ENGINE=InnoDB DEFAULT CHARSET=latin1;