i have been trying to import a Postgresql dump with my pgadmin3 interface but im running into problems. These dump was generated with pg_dump dbname > dump_file.sql
ERROR: syntax error at or near "\"
LINE 1903: \.
^
********** Error **********
ERROR: syntax error at or near "\"
SQL state: 42601
Character: 45693
the code:
--
-- Data for Name: auth_group; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY auth_group (id, name) FROM stdin;
\.
thanks
PgAdmin-III's SQL window unfortunately does not understand psql backslash commands, COPY ... FROM STDIN, etc.
You must restore with psql.
psql -f dump_file.sql
Related
I installed Postgresql on the Redhat Linux server and try to import the dump into the database At that time I'll get a syntax error.
sudo -u postgres -i psql db_test < data.sql
psql -h localhost -U postgres -W -d postgres < data.sql
Iam used these two commands to import data. At that time I'll get syntax error like this.
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `comment_details`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `comment_details` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `comment_details` WRITE;
^
ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `comment_details` VALUES (3,1140,'ANAKAPALLI MAN...
^
ERROR: syntax error at or near "UNLOCK"
LINE 1: UNLOCK TABLES;
^
ERROR: syntax error at or near "`"
LINE 1: DROP TABLE IF EXISTS `directory_org_details`;
^
ERROR: syntax error at or near "`"
LINE 1: CREATE TABLE `directory_org_details` (
^
ERROR: syntax error at or near "`"
LINE 1: LOCK TABLES `directory_org_details` WRITE;
^
invalid command \'s
invalid command \'s
invalid command \'s
ERROR: syntax error at or near "`"
LINE 1: INSERT INTO `directory_org_details` VALUES (1,'Daniel\'s Cri...
Please Help regarding This issue. Thanks in Advance.
I have to use SQL for the very first time. I downloaded data from French Public Service Open Data (https://cerema.app.box.com/v/dvfplus-opendata/folder/160785684885). I also downloaded Postgres App and PgAdmin 4. The file of interest is a dump, with a .sql extension. I created a database called "DVF" directly in PgAdmin.
Following all the tutorials online and the help here I tried to import the file using "Backup" and "Restore" commands, as well as lines directly from the terminal. I have a "success" message when I use Backup or Restore in PgAdmin, but always an error message from the Terminal (by clicking on DVF in Postgres App).
[DVF=# ./psql -U postgres DVF < /Users/Menica/dpts.sql;
>ERROR : syntax error at or near "."
[DVF=# psql -h localhost -p 5432 -U postgres -d DVF -f dpts.sql;
>ERROR: syntax error at or near "psql"
Furthermore, even with "success" messages from Backup/Restore, my tables aren't in PgAdmin after the Refresh.
I don't know if it can help but here are some directories :
The file : /Users/Menica/dpts.sql
PostGres App : /Library/PostgreSQL/9.3
=> There is a lot of folders there, like "bin"
Terminal by default : /bin/zhs
UPDATE
To dump the database I used the following in psql :
DVF-# pg_dump DVF > /Users/Menica/dpts.sql;
ERROR: syntax error at or near "pgdump"
LINE 1: pg_dump DVF > /Users/Menica/dpts.sql
^
The first 25 lines of the dpts.sql file are the following :
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.25
-- Dumped by pg_dump version 9.5.25
-- Started on 2022-04-14 15:50:09 CEST
SET statement_timeout = 0;
SET lock_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;
--
-- TOC entry 34 (class 2615 OID 631938251)
-- Name: dvf_d2a; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA dvf_d2a;
--
-- TOC entry 35 (class 2615 OID 632173840)
-- Name: dvf_d2b; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA dvf_d2b;
SET default_tablespace = '';
SET default_with_oids = false;
I want to import a CSV file to PostgreSQL.
Shown below is the syntax used to import a CSV file to a created table i.e. salary_supervisor in PostgreSQL,
COPY salary_supervisor
FROM 'X:\XX\XXX\XXX\XXX\XXX\XXX\supervisor_salaries.csv' /* File path */
WITH (FORMAT CSV, HEADER);
However, it indicates an error as shown below,
ERROR: could not open file "X:\XX\XXX\XXX\XXX\XXX\XXX\supervisor_salaries.csv" for reading: Permission denied
HINT: COPY FROM instructs the PostgreSQL server process to read a file. You may want a client-side facility such as psql's \copy.
SQL state: 42501
Since an error was shown above, the below syntax was used to import the CSV file to PostgreSQL,
\copy (Select * From salary_supervisor)
FROM 'X:\XX\XXX\XXX\XXX\XXX\XXX\supervisor_salaries.csv' /* File path */
WITH (FORMAT CSV, HEADER);
However, it also indicated a syntax error shown below,
ERROR: syntax error at or near "\"
LINE 1: \copy (Select * From salary_supervisor)
^
SQL state: 42601
Character: 1
I am entirely new to psql and not particularly familiar with some terms. I am following instructions on an ETL process for mimic-in the link here: https://github.com/chichukw/mimic-omop/blob/master/README-run-etl.md. When I run this code, it shows no output but this error:
syntax error at or near "psql"
I have tried adding semicolon, removing the psql part and removing the quotes and dollar sign but I still get this syntax error on the first character regardless.
psql "$MIMIC" postgres_create_mimic_id.sql;
I expect concept ids to be created after running this code on the server using the jupyter terminal.
The only way I can think of how you could get that output/error is if you did this:
[root#foo /]# psql
psql (11.5)
Type "help" for help.
postgres=# psql "$MIMIC" postgres_create_mimic_id.sql;
ERROR: syntax error at or near "psql"
LINE 1: psql "$MIMIC" postgres_create_mimic_id.sql;
^
postgres=#
Instead, I think you should be doing this:
[root#foo /]# export MIMIC='host=localhost dbname=postgres user=postgres options=--search_path=mimiciii'
[root#foo /]# psql "$MIMIC" -f postgres_create_mimic_id.sql;
Disclosure: I am an EnterpriseDB (EDB) employee
I'm having a MySQL dump from Version 4.0.21. I converted it to UTF-8 to fit with the special characters such as (Ü, ü, Ä, ä, Ö, ö, ß). Now I have to import it into the latest MySQL Version 5.5.36. All data have been imported but an error occurred at the end.
ERROR 1064 (42000) at line 80769: You have an error in your SQL syntax...use near '' at line 1
The empty string and the line numbers are confusing me. Importing with phpMyAdmin results the same as command line does, with the command:
mysql -u root -p bugtracker < E:\mantisUTF.dump
The import with the original dump from Version 4.0.21 is working perfect but without the above mentioned special characters.
First Lines of the dump file:
-- MySQL dump 9.11
--
-- Host: localhost Database: Mantis
-- ------------------------------------------------------
-- Server version 4.0.21-debug
--
-- Table structure for table `mantis_bug_file_table`
--
Last Lines (80768 & 80769):
INSERT INTO mantis_user_table VALUES (57,'fullName','firstName lastName','emailAdress','dd1875c93e8f17a24ebaf9c902b7165a','2014-01-29 13:43:21','2014-03-26 13:22:47',1,0,55,14,0,0,'1b886436b0c62598ab66e40ae89f0c016dc5777ebb601a73f2a07536281113ae'
Thanks in advance.
Relax
By rechecking my question i found the problem. The problem was a missing ')' at the end of the dump file.
Last line:
INSERT INTO mantis_user_table VALUES (57,'fullName','firstName lastName','emailAdress','dd1875c93e8f17a24ebaf9c902b7165a','2014-01-29 13:43:21','2014-03-26 13:22:47',1,0,55,14,0,0,'1b886436b0c62598ab66e40ae89f0c016dc5777ebb601a73f2a07536281113ae')