I am a little embarrassed asking this question but I seem to be stumped.
I am using MySQL 5.7 and am trying to upload to my online server which has MySQL 5.6. phpMyAdmin was used create the database. I get the same error when I try to restore the database in my local phpMyAdmin (part of my WAMP server).
I have also studied the My SQL reference documentation as well as several internet searches. Here is the error:
SQL query:
DROP TABLE IF EXISTS `heyx1_assets`;
CREATE TABLE `heyx1_assets` (
`id` int(10) UNSIGNED NOT NULL COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0' COMMENT
) ;
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 ')' at line 4
Any help will be appreciated. My client is becoming very impatient.
You have a COMMENT, but no comment. You need a string after COMMENT:
CREATE TABLE `heyx1_assets` (
`id` int(10) UNSIGNED NOT NULL COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0' COMMENT 'Comment goes here'
---------------------------------------------------^
) ;
Which phpMyAdmin versions are you using on each server? This seems like it may have been a bug with an older version of phpMyAdmin (which had trouble exporting in a similar way to what you're describing); I suggest you upgrade to the latest (which is currently 4.6.5.2).
You can also edit the SQL file to manually fix the COMMENT as shown by Gordon Linoff.
Related
I have an old database. Am uploading it into SQL using phpmyadmin But when I want to import it I get an error. It seems the first table even cannot get imported:
CREATE TABLE `manager` (
`username` VARCHAR(20) NOT NULL,
`password` VARCHAR(50) NOT NULL,
`email` VARCHAR(100) NOT NULL ,
`deposit` VARCHAR( 50 ) DEFAULT '0' NOT NULL
)
TYPE = MYISAM
CHARACTER SET utf8 COLLATE utf8_new_ci
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 'TYPE = MYISAM CHARACTER SET utf8 COLLATE utf8_new_ci' at line 7
How can I resolve this issue?
ENGINE=MyISAM is what you should be using I believe. Also, its probably a good idea to encapsulate your field names like this :
`username` and `password` just to prevent mysql/mariadb picking them up as reserved words.
TYPE is not a valid table_option in Mysql 8, see Manual at https://dev.mysql.com/doc/refman/8.0/en/create-table.html. There is a list of all valid table_options beginning in line 110.
I have an old database
Maybe you can give us more information about your used database by runing the mysql command
SELECT VERSION();
I am trying to add a table to my schema in MySQL workbench and I keep getting an error.
Message Log:
Executing:
CREATE TABLE `TestVisual`.`arc` (
`arcid` INT NOT NULL DEFAULT 0 COMMENT '',
`name` VARCHAR(45) NULL DEFAULT '' COMMENT '',
PRIMARY KEY (`arcid`) COMMENT '');
Operation failed: There was an error while applying the SQL script to the database.
ERROR 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 'COMMENT '')' at line 4
SQL Statement:
CREATE TABLE `TestVisual`.`arc` (
`arcid` INT NOT NULL DEFAULT 0 COMMENT '',
`name` VARCHAR(45) NULL DEFAULT '' COMMENT '',
PRIMARY KEY (`arcid`) COMMENT '')
I have tried to follow a tutorial but I still get the error. There are other tables already on this server and I am able to change their data along with add and delete columns. I am also on the root user.
Barmar answered it above in the comments. This server is using an older version of MySQL so there are not allowed to be COMMENT in the sql. Deleted them and it worked fine.
I have a script that I got online that I wanted to try out. Everything has worked so far except for the last step which is to import a .sql file using phpmyadmin. The .sql script is
CREATE TABLE lil_urls (
id varchar(255) NOT NULL default '',
url text,
date timestamp(14) NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;
My server version is 5.5.34-cll - MySQL Community Server (GPL)
The error I get says
#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 '(14) NOT NULL, PRIMARY KEY (id) ) TYPE=MyISAM' at line 4
How do I properly import this file?
Thanks
I am very new to MySQL so before you decide to downvote this please just add a comment and I will delete the post. I am following a tutorial on android-hive, http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/, that uses MySQL as a database for holding user information. I set up MySQL on an AWS EC2 Linux instance, along with apache tomcat etc. etc. The tutorial says:
Open your mysql console or phpmyadmin and run following query to create database
and users table:
create database android_api /** Creating Database **/
use android_api /** Selecting Database **/
create table users(
uid int(11) primary key auto_increment,
unique_id varchar(23) not null unique,
name varchar(50) not null,
email varchar(100) not null unique,
encrypted_password varchar(80) not null,
salt varchar(10) not null,
created_at datetime,
updated_at datetime null
); /** Creating Users Table **/
I connect to my Linux instance via SSH and start MySQL and run the query that is stated in the tutorial. I get the following error:
ERROR 1064 (42000): 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
'use android_api
create table users(
uid int(11) primary key auto_increment,
' at line 3
I really have no idea how to solve this and I appreciate any help given, thank you for your time.
seems like you have missed the statement separator. try and use ";" at the end of each query.
In your code there is
use android_api //this one is correct
but in error message the quote is
uses android_api
so it looks like this code is not exactly same that You have problem with.
If anyone encounters this in the future. The solution is to use the create database query first, then after creation of the database use the "use" query and the create table query together.
there is a syntex mistake use ";" after second statement like
use android_api;
it worked for me :-)
I am trying to copy a MyIsam dataBase from my a remote server to my local machine for testing. I am using phpMyAdmin on the remote server. I select the database and then export. When I try to import (using mamp, phMyAdmin) I get the following error message
Error
SQL query:
CREATE TABLE IF NOT EXISTS `assignments` (
`uid` int( 11 ) default NULL ,
`rid` int( 11 ) default NULL ,
`semester` varchar( 255 ) default NULL ,
`year` int( 11 ) default NULL
) TYPE = MYISAM ;
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' at line 6
Please Help!
Thanks
Try the trick proposed by Reza (Type=InnoDB) but I use MAMP on local machines and it can support either InnoDB/MyISAM… Which version of MAMP do you use ? (I use the free one)
Maybe your local database doesn't support MyISAM type? Does it have to be MyISAM? You can try changing it to 'TYPE=InnoDB' in the sql dump text file