error upload .sql file of wordpress site - mysql

this is the 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 'AS ical subscribe access key,
created_on datetime DEFAULT NULL,
`updated' at line 20
Erreur
requête SQL:
-- --------------------------------------------------------
--
-- Structure de la table `pec_calendars`
--
CREATE TABLE `pec_calendars` (
`id` INT( 11 ) UNSIGNED NOT NULL ,
`type` ENUM( 'user', 'group', 'url' ) DEFAULT 'user',
`user_id` INT( 11 ) UNSIGNED DEFAULT NULL ,
`name` VARCHAR( 100 ) DEFAULT NULL ,
`description` TEXT,
`color` VARCHAR( 7 ) DEFAULT NULL ,
`admin_id` INT( 11 ) DEFAULT NULL ,
`status` ENUM( 'on', 'off' ) DEFAULT 'on',
`show_in_list` ENUM( '0', '1' ) DEFAULT NULL ,
`public` TINYINT( 3 ) UNSIGNED DEFAULT '0',
`reminder_message_email` TEXT,
`reminder_message_popup` TEXT,
`access_key` VARCHAR( 32 ) DEFAULT NULL COMMENT AS `ical subscribe access key` ,
`created_on` DATETIME DEFAULT NULL ,
`updated_on` DATETIME DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8;

Guess your query should be:
CREATE TABLE pec_calendars
(
id INT(11) UNSIGNED NOT NULL,
type ENUM('user', 'group', 'url') DEFAULT 'user',
user_id INT(11) UNSIGNED DEFAULT NULL,
name VARCHAR(100) DEFAULT NULL,
description TEXT,
color VARCHAR(7) DEFAULT NULL,
admin_id INT(11) DEFAULT NULL,
status ENUM('on', 'off') DEFAULT 'on',
show_in_list ENUM('0', '1') DEFAULT NULL,
public TINYINT(3) UNSIGNED DEFAULT '0',
reminder_message_email TEXT,
reminder_message_popup TEXT,
access_key VARCHAR(32) DEFAULT NULL,
created_on DATETIME DEFAULT NULL,
updated_on DATETIME DEFAULT NULL
)
engine = innodb
DEFAULT charset = utf8;

Related

MySQL- Invalid default value for 'lasttime'

SQL sorgusu:
CREATE TABLE online(
idonline İNT( 10 ) UNSİGNED NOT NULL AUTO_INCREMENT ,
ip VARCHAR( 16 ) ,
domain VARCHAR( 100 ) ,
FKiduyeler İNT( 10 ) UNSİGNED,
lasttime TİMESTAMP DEFAULT 'CURRENT_TIMESTAMP',
PRIMARY KEY ( idonline ) ,
KEY online_index3587( ip ) ,
KEY online_index3588( domain ) ,
KEY online_index3592( FKiduyeler ) ,
KEY online_index3604( lasttime )
);
MySQL çıktısı: Belgeler
#1067 - Invalid default value for 'lasttime'
Before everthing sorry about my english; when l upload my db ,l got this proglem.Please help me.Thanks
CURRENT_TIMESTAMP instead of 'CURRENT_TIMESTAMP'
I instead of İ at multiple places.
CREATE TABLE `online`(
idonline INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
ip VARCHAR( 16 ) ,
domain VARCHAR( 100 ) ,
FKiduyeler INT( 10 ) UNSIGNED,
lasttime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, -- lose the single quotes here
PRIMARY KEY ( idonline ) ,
KEY online_index3587( ip ) ,
KEY online_index3588( domain ) ,
KEY online_index3592( FKiduyeler ) ,
KEY online_index3604( lasttime )
);
Thank for helping, but when l do that I'm getting this problem:
CREATE TABLE visitor_chats ( visitor_id varchar(32) NOT NULL,
browser_id varchar(32) NOT NULL, visit_id varchar(32) NOT NULL,
chat_id int(11) unsigned NOT NULL, fullname varchar(255) NOT NULL,
email varchar(255) NOT NULL, company varchar(255) NOT NULL, status
tinyint(1) unsigned NOT NULL, typing tinyint(1) unsigned NOT NULL,
waiting tinyint(1) unsigned NOT NULL, area_code varchar(255) NOT NULL,
first_active int(10) unsigned NOT NULL, last_active int(10) unsigned
NOT NULL, qpenalty int(10) unsigned NOT NULL, request_operator
varchar(32) NOT NULL, request_group varchar(32) NOT NULL, question
varchar(255) NOT NULL, customs text NOT NULL, allocated int(11)
unsigned NOT NULL, internal_active tinyint(1) unsigned NOT NULL,
internal_closed tinyint(1) unsigned NOT NULL, internal_declined
tinyint(1) unsigned NOT NULL, external_active tinyint(1) unsigned NOT
NULL, external_close tinyint(1) unsigned NOT NULL, exit int(11) [...]
MySQL 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 'exit int(11) unsigned NOT NULL,PRIMARY KEY
(visitor_id,browser_id,visit_id,c' at line 26"

Error in MySQL database code while importing

my code :
CREATE TABLE IF NOT EXISTS `friends` (
`Id` INT(10) NOT NULL AUTO_INCREMENT,
`providerid` INT(10) NOT NULL AUTO_INCREMENT,
`requestid` INT(10) NOT NULL AUTO_INCREMENT,
`status` BINARY(1) NOT NULL,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `messages` (
`Id` INT(255) NOT NULL AUTO_INCREMENT,
`fromuid` INT(255) NOT NULL,
`touid` INT(255) NOT NULL,
`sentdt` DATETIME NOT NULL,
`read` TINYINT(1) NOT NULL DEFAULT '0',
`readdt` DATETIME DEFAULT NULL,
`messagetext` LONGTEXT CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `users` (
`Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`username` VARCHAR(45) NOT NULL DEFAULT '',
`password` VARCHAR(32) NOT NULL DEFAULT '',
`email` VARCHAR(45) NOT NULL DEFAULT '',
`date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
`authenticationTime` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`userKey` VARCHAR(32) NOT NULL DEFAULT '',
`IP` VARCHAR(45) NOT NULL DEFAULT '',
`port` INT(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`)
);
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 'CREATE TABLE IF NOT EXISTS messages (
Id int(255) NOT NULL AUTO_INCREMENT,' at line 8
so plz help me correcting the code...
Thank you
There are few errors in your script.
1) there can be only one autoincrement key and it must be defined as a key
2) spelling mistable in third query of DEFAULT in
`email` varchar(45) NOT NULL DEFAULT '',
3) DEFAULT keyword used twice in 3rd query for below field and missing NULL for NOT NULL
`authenticationTime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
CORRECT query:-
CREATE TABLE IF NOT EXISTS `friends` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`providerid` int(10) NOT NULL ,
`requestid` int(10) NOT NULL ,
`status` binary(1) NOT NULL ,
PRIMARY KEY (`Id`));
CREATE TABLE IF NOT EXISTS `messages` (
`Id` int(255) NOT NULL AUTO_INCREMENT,
`fromuid` int(255) NOT NULL,
`touid` int(255) NOT NULL,
`sentdt` datetime NOT NULL,
`read` tinyint(1) NOT NULL DEFAULT '0',
`readdt` datetime DEFAULT NULL,
`messagetext` longtext CHARACTER SET utf8 NOT NULL ,
PRIMARY KEY (`Id`)
);
CREATE TABLE IF NOT EXISTS `users` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(45) NOT NULL DEFAULT '',
`password` varchar(32) NOT NULL DEFAULT '',
`email` varchar(45) NOT NULL DEFAULT '',
`date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`status` tinyint(3) unsigned NOT NULL DEFAULT '0',
`authenticationTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`userKey` varchar(32) NOT NULL DEFAULT '',
`IP` varchar(45) NOT NULL DEFAULT '',
`port` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`)
)

Can't import MySQL database in phpMyAdmin

I am importing database in phpMyAdmin but having errors. I tried too much but showing same errors, here is SQL database:
CREATE TABLE `business` (
`b_id` bigint(20) NOT NULL AUTO_INCREMENT,
`b_title` text,
`b_lastmodified` datetime DEFAULT NULL,
`b_detail` text,
`b_banner_image` varchar(250) DEFAULT NULL,
`b_cat_id` int(10) DEFAULT '100',
`b_subcat_id` int(10) DEFAULT NULL,
`b_tags` text,
`b_user_id` bigint(20) DEFAULT NULL,
`b_isactive` tinyint(1) DEFAULT '0' COMMENT 'admin will approve it',
`b_created_on` datetime DEFAULT NULL,
`b_views` bigint(20) DEFAULT '0' COMMENT 'number of times this is viewed',
PRIMARY KEY (`b_id`)
) ENGINE=MyISAM AUTO_INCREMENT=764 DEFAULT CHARSET=utf8;
INSERT INTO `business` (`b_id`, `b_title`, `b_lastmodified`, `b_detail`, `b_banner_image`, `b_cat_id`, `b_subcat_id`, `b_tags`, `b_user_id`, `b_isactive`, `b_created_on`, `b_views`) VALUES ('1', 'Couple Names Silver Pendant', '2014-01-15 02:25:02', '', 'itm_couple-names-silver-pendant2013-03-25_22-07-16_1.jpg', '35', '0', 'love pendant,name pictures,silver name pendant,couple name pendant,locket of love,chain of name,fb display photos', '1', '1', '2013-03-25 22:06:53', '7263');
And showing these errors:
Error
SQL query:
CREATE TABLE `business` (
`b_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
`b_title` TEXT,
`b_lastmodified` DATETIME DEFAULT NULL ,
`b_detail` TEXT,
`b_banner_image` VARCHAR( 250 ) DEFAULT NULL ,
`b_cat_id` INT( 10 ) DEFAULT '100',
`b_subcat_id` INT( 10 ) DEFAULT NULL ,
`b_tags` TEXT,
`b_user_id` BIGINT( 20 ) DEFAULT NULL ,
`b_isactive` TINYINT( 1 ) DEFAULT '0' COMMENT 'admin will approve it',
`b_created_on` DATETIME DEFAULT NULL ,
`b_views` BIGINT( 20 ) DEFAULT '0' COMMENT 'number of times this is viewed',
PRIMARY KEY ( `b_id` )
) ENGINE = MYISAM AUTO_INCREMENT =764 DEFAULT CHARSET = utf8;
MySQL said: Documentation
#1046 - No database selected
In phpMyAdmin make a new database or select an existing database. Then import the SQL file.
or
Include below lines into your first line of the sql script.
create database database_name;
use database_name;
You have not selected a database in which you want to create the table and start the import. This is why you get that error.
You should click on the database you are importing in, before you go to the query window and execute the query.
Another option is to select the database, like this:
USE `database_name`;
CREATE TABLE `business` (
`b_id` bigint(20) NOT NULL AUTO_INCREMENT,
`b_title` text,
`b_lastmodified` datetime DEFAULT NULL,
`b_detail` text,
`b_banner_image` varchar(250) DEFAULT NULL,
`b_cat_id` int(10) DEFAULT '100',
`b_subcat_id` int(10) DEFAULT NULL,
`b_tags` text,
`b_user_id` bigint(20) DEFAULT NULL,
`b_isactive` tinyint(1) DEFAULT '0' COMMENT 'admin will approve it',
`b_created_on` datetime DEFAULT NULL,
`b_views` bigint(20) DEFAULT '0' COMMENT 'number of times this is viewed',
PRIMARY KEY (`b_id`)
) ENGINE=MyISAM AUTO_INCREMENT=764 DEFAULT CHARSET=utf8;
INSERT INTO `business` (`b_id`, `b_title`, `b_lastmodified`, `b_detail`, `b_banner_image`, `b_cat_id`, `b_subcat_id`, `b_tags`, `b_user_id`, `b_isactive`, `b_created_on`, `b_views`) VALUES ('1', 'Couple Names Silver Pendant', '2014-01-15 02:25:02', '', 'itm_couple-names-silver-pendant2013-03-25_22-07-16_1.jpg', '35', '0', 'love pendant,name pictures,silver name pendant,couple name pendant,locket of love,chain of name,fb display photos', '1', '1', '2013-03-25 22:06:53', '7263');

SQL syntax error

CREATE TABLE `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`type` ENUM( `member` , `admin` ) NOT NULL ,
`username` VARCHAR( 30 ) NOT NULL ,
`email` VARCHAR( 80 ) NOT NULL ,
`pass` VARBINARY( 32 ) NOT NULL ,
`first_name` VARCHAR( 20 ) NOT NULL ,
`last_name` VARCHAR( 40 ) NOT NULL ,
`date_expires` DATE NOT NULL ,
`date_created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ,
`date_modified` TIMESTAMP NOT NULL DEFAULT `0000-00-00 00:00:00` ,
PRIMARY KEY ( `id` ) ,
UNIQUE KEY `username` ( `username` ) ,
UNIQUE KEY `email` ( `email` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8;
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 'member,admin) NOT NULL, username VARCHAR(30) NOT NULL,
email VARCHAR(80)' at line 3
The shared server I am using, uses 4.4. Thanks for reading. I am an absolute novice, having only been learning php/mysql for one month, so please speak in layman's terms.
You need to quote ENUM values
type ENUM( 'member' , 'admin' ) NOT NULL ,
not backtick them as you do now
Same thing for this line
`date_modified` TIMESTAMP NOT NULL DEFAULT `0000-00-00 00:00:00`
should be
`date_modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00'
This page indicates that your ENUM values should be strings, so need to be surrounded by single quotes.
type ENUM( 'member' , 'admin' ) NOT NULL
okey fixed it here is it :)
CREATE TABLE `users` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
type ENUM( 'member' , 'admin' ) NOT NULL ,
`username` varchar(30) NOT NULL default '',
`password` varchar(255) NOT NULL default '',
`first_name` varchar (15) NOT NULL,
`last_name` varchar (30) NOT NULL,
`gender` ENUM('male', 'female') NOT NULL default 'male',
`email` varchar(50) NOT NULL default '',
`skype` varchar(50) NOT NULL default 'Not Specified',
`facebook` varchar(150) NOT NULL default 'Not Specified',
`location` varchar(100) NOT NULL default 'Not Specified',
PRIMARY KEY (`id`),
UNIQUE KEY (`email`),
KEY (`email`, `password`)
) ENGINE = MYISAM DEFAULT CHARSET = utf8;

SQL CREATE TABLE Error

The Answer was that I was using incorrect quotation marks instead of backticks. Stupid syntax hilighter tricked me.
I've been stuck on this one simple(ish) thing for the last 1/2 hour so I thought I might try to get a quick answer here.
What exactly is incorrect about my SQL syntax, assuming I'm using mysql 5.1
CREATE TABLE 'users' (
'id' INT(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
'username' VARCHAR(20) NOT NULL,
'password' VARCHAR(40) NOT NULL,
'salt' VARCHAR(40) DEFAULT NULL,
'email' VARCHAR(80) NOT NULL,
'created_on' INT(11) UNSIGNED NOT NULL,
'last_login' INT(11) UNSIGNED DEFAULT NULL,
'active' TINYINT(1) UNSIGNED DEFAULT NULL,
)
ENGINE InnoDB;
The error I get is:
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 ''users';
CREATE TABLE 'users' (
'id' INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,' at line 3
Elapsed Time: 0 hr, 0 min, 0 sec, 0 ms.
Also, does anyone have any good tutorials about how to use Zend_Auth for complete noobs?
Thanks.
Table and column identifiers are quoted using backticks (or double quotes if you've configured them).
Additionally you have a comma at the end of your column list.
CREATE TABLE `users` (
`id` MEDIUMINT( 8 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR( 20 ) NOT NULL,
`password` VARCHAR( 40 ) NOT NULL,
`salt` VARCHAR( 40 ) DEFAULT NULL,
`email` VARCHAR( 80 ) NOT NULL,
`created_on` INT( 11 ) UNSIGNED NOT NULL,
`last_login` INT( 11 ) UNSIGNED DEFAULT NULL,
`active` TINYINT( 1 ) UNSIGNED DEFAULT NULL
) ENGINE InnoDB
You are using single quotes instead of backticks for your table and field names, which is wrong. There should also be an equals sign between ENGINE and InnoDB.
Here's the fixed SQL:
CREATE TABLE `users` (
`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`username` VARCHAR(20) NOT NULL,
`password` VARCHAR(40) NOT NULL,
`salt` VARCHAR(40) DEFAULT NULL,
`email` VARCHAR(80) NOT NULL,
`created_on` INT(11) UNSIGNED NOT NULL,
`last_login` INT(11) UNSIGNED DEFAULT NULL,
`active` TINYINT(1) UNSIGNED DEFAULT NULL
)
ENGINE = InnoDB;