ERROR 1064 (42000) while importing .sql file into MySQL - import

I'm trying to import a client's database dump into my MySQL 5.5.27 (for Win64) running on Windows Vista 64 bit. However, I get
ERROR 1064 (42000) at line 24: 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 8
I've pasted the first several lines of the dump file below:
CREATE DATABASE IF NOT EXISTS `foobar` /*!40100 DEFAULT CHARACTER SET utf8 */;
USE `foobar`;
-- MySQL dump 10.13 Distrib 5.5.16, for osx10.5 (i386)
--
-- Host: localhost Database: foobar
-- ------------------------------------------------------
-- Server version 5.5.21
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET #OLD_TIME_ZONE=##TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET #OLD_SQL_NOTES=##SQL_NOTES, SQL_NOTES=0 */;
--
-- Temporary table structure for view `reference`
--
CREATE TABLE `reference` (
`xyz` varchar(50),
`ABC` varchar(50),
`asdf` varchar(50),
`abcd` varchar(7),
`Axe` varchar(255),
`Age` varchar(255)
) ENGINE=MyISAM */;
SET character_set_client = #saved_cs_client;

Try to change the script in this way -
...
CREATE TABLE `reference` (
`xyz` varchar(50),
`ABC` varchar(50),
`asdf` varchar(50),
`abcd` varchar(7),
`Axe` varchar(255),
`Age` varchar(255)
) ENGINE=MyISAM */;
SET character_set_client = #saved_cs_client;*/
or just remove that part -
...
CREATE TABLE `reference` (
`xyz` varchar(50),
`ABC` varchar(50),
`asdf` varchar(50),
`abcd` varchar(7),
`Axe` varchar(255),
`Age` varchar(255)
);

Related

pg_dump success, but no data in backed file

I use
pg_dump -d xx_sjcbhs --table=wd555.ft_bjgzflcbmxb --column-inserts > e:\temp\ontable2.sql
backup a table. The command is Ok, but the backup file have no insert statement, and no data.
--
-- PostgreSQL database dump
--
-- Dumped from database version 14.5
-- Dumped by pg_dump version 14.5
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
--
-- Name: ft_bjgzflcbmxb; Type: TABLE; Schema: wd555; Owner: postgres
--
CREATE TABLE wd555.ft_bjgzflcbmxb (
xxbsm text NOT NULL,
xxmc text NOT NULL,
tyshxydm text NOT NULL,
id text NOT NULL,
yyyymm text NOT NULL,
bjdm text NOT NULL,
cbflbm text NOT NULL,
cbfl text NOT NULL,
je numeric(18,2) NOT NULL,
zgh text NOT NULL,
rysxdm text NOT NULL,
ftbz text,
ftsm text,
dftje numeric(18,2) NOT NULL,
zrs numeric(18,2) NOT NULL,
bjrs numeric(18,2) NOT NULL
)
PARTITION BY LIST (yyyymm);
--
-- PostgreSQL database dump complete
You got what you requested, because a partitioned table contains no data. You have to dump the partitions as well if you want to dump the data. To makes that easier, note that the --table option accepts a pattern as argument, so that you don't have to enumerate all partitions.

how to get error messages to a file in BTEQ for teradata

i write some SQL commands in batch file (.bteq files), the bteq file is as follows:
.logon localhost:1025/dbc,dbc
SELECT 1 FROM dbc.tables WHERE databasename = 'customerservice' AND TABLENAME
= 'accounts';
.if activitycount <>0 then drop table customerservice.accounts;
CREATE SET TABLE CustomerService.accounts ,FALLBACK ,
NO BEFORE JOURNAL,
NO AFTER JOURNAL,
CHECKSUM = DEFAULT,
DEFAULT MERGEBLOCKRATIO
(
ACCOUNT_NUMBER INTEGER NOT NULL,
STREET_NUMBER INTEGER,
STREET CHAR(25) CHARACTER SET LATIN NOT CASESPECIFIC,
CITY CHAR(20) CHARACTER SET LATIN NOT CASESPECIFIC,
STATE CHAR(2) CHARACTER SET LATIN NOT CASESPECIFIC,
ZIP_CODE INTEGER,
BALANCE_FORWARD DECIMAL(10,2),
BALANCE_CURRENT DECIMAL(10,2))
UNIQUE PRIMARY INDEX ( ACCOUNT_NUMBER );
insert into customerservice.accounts
values(20031303,559,'LaSalleAve','SantaMonica','CA',94123,4550.00,4550.00);
insert into customerservice.accounts values(20033587,506,'SomersetWay',
'HermosaBeach','CA',90365,7770.00,7770.00);insert into
customerservice.accounts
values(20033118,900,'9thStreet','HermosaBeach','CA',90365,3080.00,3080.00);
insert into customerservice.accounts values
(20032649,924,'OregonTrail','HermosaBeach','CA',90365,8200.00,8200.00);
insert into customerservice.accounts values
(20030691,987,'ComptonPlace','SantaMonica','CA',94123,8240.00,8240.00);
then i run this bteq file like this:
bteq < test.bteq 2>error.txt
what i want to is redirect error to error.txt, but seems it do not work, maybe it is because 2 is just for standard error, but the SQL error is not standard system error ?
if so, then is there any ways we can redirect SQL error to a file ?

Eximstats dissapeared/eliminated after cpanel upgrade

Today I was reviewing my server and the Eximstats database dissapeared! but I see like a new design so I assumed that Cpanel/WHM was autoupdated.
I thought it was a mistake and i have to just repair the database, but the email delivery log still works, so I do not know where this information is being pulled from.
I tried repairing the database and the repair tool deletes the database! Is like a new structure!
I am wondering if anybody knows if there is any version of exim that does not use eximstats database, if the information is pulled from a different database or file, and how to read again this database.
I need that database as I had an app developed using this database.
Thanks for your help!
Since version 64, cPanel moved eximstats data from MySQL to SQLite3. The new database is located in /var/cpanel/eximstats_db.sqlite3 and the tables are slightly changed. The time is now recorded as unix timestamps and a few things are gone (like the unique ids which were mostly pointless anyway). Hope this helps.
The eximstats database structure is as follows (the default tables as per cPanel/WHM install):
-- MySQL dump 10.15 Distrib 10.0.30-MariaDB, for Linux (x86_64)
--
-- Host: dbv1.gazduire.ro Database: eximstats
-- ------------------------------------------------------
-- Server version 5.5.27
/*!40101 SET #OLD_CHARACTER_SET_CLIENT=##CHARACTER_SET_CLIENT */;
/*!40101 SET #OLD_CHARACTER_SET_RESULTS=##CHARACTER_SET_RESULTS */;
/*!40101 SET #OLD_COLLATION_CONNECTION=##COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET #OLD_TIME_ZONE=##TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET #OLD_SQL_NOTES=##SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `defers`
--
DROP TABLE IF EXISTS `defers`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `defers` (
`mailtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`msgid` char(16) NOT NULL DEFAULT '',
`email` char(255) NOT NULL DEFAULT '',
`transport_method` char(45) NOT NULL DEFAULT 'remote_smtp',
`host` char(255) NOT NULL DEFAULT '',
`ip` char(46) NOT NULL DEFAULT '',
`message` char(240) NOT NULL DEFAULT '',
`router` char(65) NOT NULL DEFAULT '',
`deliveryuser` char(30) NOT NULL DEFAULT '',
`deliverydomain` char(255) NOT NULL DEFAULT '',
`unique_id` int(11) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`mailtime`,`msgid`,`email`,`unique_id`),
KEY `email_mailtime_index` (`email`,`mailtime`),
KEY `msgid_mailtime_index` (`msgid`,`mailtime`),
KEY `deliverydomain_mailtime_index` (`deliverydomain`,`mailtime`),
KEY `deliveryuser_mailtime_index` (`deliveryuser`,`mailtime`),
KEY `email_deliveryuser_mailtime_index` (`email`,`deliveryuser`,`mailtime`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `failures`
--
DROP TABLE IF EXISTS `failures`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `failures` (
`mailtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`msgid` char(16) NOT NULL DEFAULT '',
`email` char(255) NOT NULL DEFAULT '',
`transport_method` char(45) NOT NULL DEFAULT 'remote_smtp',
`host` char(255) NOT NULL DEFAULT '',
`ip` char(46) NOT NULL DEFAULT '',
`message` char(240) NOT NULL DEFAULT '',
`router` char(65) NOT NULL DEFAULT '',
`deliveryuser` char(30) NOT NULL DEFAULT '',
`deliverydomain` char(255) NOT NULL DEFAULT '',
`unique_id` int(11) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`mailtime`,`msgid`,`email`,`unique_id`),
KEY `email_mailtime_index` (`email`,`mailtime`),
KEY `deliverydomain_mailtime_index` (`deliverydomain`,`mailtime`),
KEY `deliveryuser_mailtime_index` (`deliveryuser`,`mailtime`),
KEY `email_deliveryuser_mailtime_index` (`email`,`deliveryuser`,`mailtime`),
KEY `msgid_mailtime_index` (`msgid`,`mailtime`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `sends`
--
DROP TABLE IF EXISTS `sends`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sends` (
`mailtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`msgid` char(16) NOT NULL DEFAULT '',
`email` char(255) NOT NULL DEFAULT '',
`processed` enum('0','1','2','3') NOT NULL DEFAULT '0',
`user` char(30) NOT NULL DEFAULT '',
`size` int(11) unsigned NOT NULL DEFAULT '0',
`ip` char(46) NOT NULL DEFAULT '',
`auth` char(30) NOT NULL DEFAULT '',
`host` char(255) NOT NULL DEFAULT '',
`domain` char(255) NOT NULL DEFAULT '',
`localsender` enum('0','1') NOT NULL DEFAULT '1',
`spamscore` double NOT NULL DEFAULT '0',
`unique_id` int(11) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`mailtime`,`msgid`,`email`,`unique_id`),
KEY `mailtime_domain_user_msgid_index` (`mailtime`,`domain`,`user`,`msgid`),
KEY `user_mailtime_index` (`user`,`mailtime`),
KEY `msgid_user_index` (`msgid`,`user`),
KEY `domain_user_mailtime_index` (`domain`,`user`,`mailtime`),
KEY `email_mailtime_user_index` (`email`,`mailtime`,`user`),
KEY `user_mailtime_spamscore_ip_index` (`user`,`mailtime`,`spamscore`,`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
--
-- Table structure for table `smtp`
--
DROP TABLE IF EXISTS `smtp`;
/*!40101 SET #saved_cs_client = ##character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `smtp` (
`mailtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`msgid` char(16) NOT NULL DEFAULT '',
`email` char(255) NOT NULL DEFAULT '',
`processed` enum('0','1','2','3') NOT NULL DEFAULT '0',
`transport_method` char(45) NOT NULL DEFAULT 'remote_smtp',
`transport_is_remote` enum('0','1','2','3') NOT NULL DEFAULT '1',
`host` char(255) NOT NULL DEFAULT '',
`ip` char(46) NOT NULL DEFAULT '',
`deliveredto` char(255) NOT NULL DEFAULT '',
`router` char(65) NOT NULL DEFAULT '',
`deliveryuser` char(30) NOT NULL DEFAULT '',
`deliverydomain` char(255) NOT NULL DEFAULT '',
`counteddomain` char(255) NOT NULL DEFAULT '',
`countedtime` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`countedhour` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`unique_id` int(11) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`mailtime`,`msgid`,`email`,`deliveredto`,`router`,`unique_id`),
KEY `msgid_index` (`msgid`),
KEY `deliverydomain_mailtime_index` (`deliverydomain`,`mailtime`),
KEY `deliveryuser_mailtime_index` (`deliveryuser`,`mailtime`),
KEY `email_mailtime_index` (`email`,`mailtime`),
KEY `email_deliveryuser_mailtime_index` (`email`,`deliveryuser`,`mailtime`),
KEY `processed_transport_is_remote_index` (`processed`,`transport_is_remote`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = #saved_cs_client */;
/*!40103 SET TIME_ZONE=#OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=#OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=#OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=#OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=#OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=#OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=#OLD_SQL_NOTES */;
-- Dump completed on 2017-04-24 23:12:19
This is taken from a WHM 11.52 server. It seems that in the latest cPanel/WHM version the database is not there anymore. I suggest you open a support ticket to cPanel and ask.
Meanwhile you can create the database from the table structure I have provided. Not sure if exim will log anything into it though since if they removed the database then the exim configuration could have changed and this could lead in no logging to the database.

Malformed string IN Default Field

I'm trying to migrate a Firebird 2.1 database to 2.5 and an error is occurring in the default field. Which charset should I use?
SET SQL DIALECT 3;
CREATE DATABASE 'F:\Sistemas\mga\DataBase\CRIAR.GDB'
USER 'SYSDBA' PASSWORD 'masterkey'
PAGE_SIZE 16384
DEFAULT CHARACTER SET NONE;
CREATE TABLE ESTOQUE (
ID INTEGER,
FORNECEDOR_ID INTEGER,
FUNCIONARIOS_ID INTEGER,
ID_TABELA INTEGER,
DATA DATE,
QUANTIDADE NUMERIC(15,2),
VALOR_UNITARIO NUMERIC(15,5) DEFAULT 0,
TABELA VARCHAR(100) CHARACTER SET NONE,
SAFRA_ID NUMERIC(18,0),
VALOR_TOTAL NUMERIC(15,2),
TIPO VARCHAR(100) CHARACTER SET NONE,
PROPRIEDADE_ID INTEGER,
PLACAS VARCHAR(100) CHARACTER SET NONE,
NOTAS VARCHAR(100) CHARACTER SET NONE,
MOTORISTA VARCHAR(100) CHARACTER SET NONE,
BLOQUEADO VARCHAR(3) CHARACTER SET NONE DEFAULT 'NÃO',
DESCRICAO BLOB SUB_TYPE 1 SEGMENT SIZE 80 CHARACTER SET NONE,
FRETE NUMERIC(15,2)
);
Error :: BLOQUEADO VARCHAR(3) CHARACTER SET NONE DEFAULT 'NÃO',
This operation is not defined for system tables.
unsuccessful metadata update.
STORE RDB$RELATION_FIELDS failed.
Malformed string.
I TRY:
SET NAMES WIN1252;
WIN1252
CHARACTER SET WIN1252,
CHARACTER SET ISO8859_1
COLLATE PT_BR
but, THIS IS OK
update ESTOQUE set BLOQUEADO='NÃO' ;
Backup database and try to restore with these options:
c:\Program Files\Firebird\Firebird_2_5\bin\gbak.exe -R O c:\temp\my_backup.FBK my_new_database.fdb
-FIX_FSS_M WIN1252 -FIX_FSS_D WIN1252 -USER SYSDBA -PAS masterkey -V

forward engineer with mysql workbench cannot create the schema

-- MySQL Workbench Forward Engineering
SET #OLD_UNIQUE_CHECKS=##UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET #OLD_FOREIGN_KEY_CHECKS=##FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET #OLD_SQL_MODE=##SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema motivian
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema motivian
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `motivian` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `motivian` ;
-- -----------------------------------------------------
-- Table `motivian`.`user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `motivian`.`user` ;
CREATE TABLE IF NOT EXISTS `motivian`.`user` (
`user_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`username` VARCHAR(100) NOT NULL,
`email` VARCHAR(100) NULL,
`password` VARCHAR(100) NOT NULL,
UNIQUE INDEX `username_UNIQUE` (`username` ASC),
PRIMARY KEY (`user_id`));
-- -----------------------------------------------------
-- Table `motivian`.`calculation`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `motivian`.`calculation` ;
CREATE TABLE IF NOT EXISTS `motivian`.`calculation` (
`category_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`calc` VARCHAR(100) NOT NULL,
`user_id` INT NULL,
`date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`category_id`),
CONSTRAINT `user_id`
FOREIGN KEY ()
REFERENCES `motivian`.`user` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION);
SET SQL_MODE=#OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=#OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=#OLD_UNIQUE_CHECKS;
This is auto generated with mysql workbench but the constraint could not be applied. I tried like this:
CONSTRAINT user_id
FOREIGN KEY (user_id)
REFERENCESmotivian.user(user_id)
ON DELETE NO ACTION
ON UPDATE NO ACTION);
but also don't work.....
This is the error:
Executing SQL script in server
ERROR: 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 ')
REFERENCES `motivian`.`user` ()
ON DELETE NO ACTION
ON UPDATE NO A' at line 8
SQL Code:
CREATE TABLE IF NOT EXISTS `motivian`.`calculation` (
`category_id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`calc` VARCHAR(100) NOT NULL,
`user_id` INT NULL,
`date_created` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`category_id`),
CONSTRAINT `user_id`
FOREIGN KEY ()
REFERENCES `motivian`.`user` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
SQL script execution finished: statements: 8 succeeded, 1 failed
Fetching back view definitions in final form.
Nothing to fetch
Your FK definition is incomplete. Youd did not specify any column. Select your foreign key in the table editor and specify column pairs in the list right to it: