I'm trying to import postgres database from dump file using command:
psql -d plus_se -f se.sql -v
I'm getting error:
psql:se.sql:22: ERROR: syntax error at or near ""
LINE 1: DROP TABLE IF EXISTS `DATABASECHANGELOG;
The dump was made using pg_dump and last time (on previous Ubuntu, I've recently installed fresh env) I was able to recreate database using this file.
Can anyone have a clue what might be wrong?
Related
As someone who is very new to working with databases/SQL I'm having trouble setting up a dump from the database Qscored, which can be found at https://zenodo.org/record/4468361#.YgTTZ-7ML0p, the first dump (ab) is the one I've worked with. The downloaded file is of type POSIX tar archive. According to the README file, these are the commands to be run in a terminal window.
cat qscored_dump_25Jan2021ab > qscored_dump_25Jan2021.tar
psql -U postgres
When in a PostGreSQL user run
CREATE DATABASE qscoreddb WITH TEMPLATE=template0 ENCODING='UTF-8';
CREATE USER dbwala WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE qscoreddb TO dbwala;
Then, in a new terminal window I run pg_restore according to
pg_restore -d qscoreddb -U postgres \path\to\qscoreddb_dump_Jan252021.tar
I then get the error message
pg_restore: error: input file does not appear to be a valid archive
Does anyone know how I might be able to solve this problem or does it mean there are problems in the original file?
I'm using PostGreSQL 14 with a Mac Monterey 12.2.
I'm a web development student and struggling to solve this problem on my own, any help would be appreciated!
Note that I'm working in an Amazon Cloud9 instance. My problem is that when I try to import an SQL file into a PostgreSQL database using the following command:
$ psql -d my_database < file_to_import.sql
I get the following error:
https:/raw.githubusercontent.com/...[removed for privacy]: No such file or directory
I know the file exists, because I'm able to navigate to it. I've tried copying the contents of the file into a new file on my desktop and then inserting the path to that file in the place of "file_to_import.sql" but that's not working either. I get the same error.
I've also tried importing via this template:
my_database=# \i ~/some/files/file_to_import.sql
But I get the same error. What's gone wrong here?
Thanks in advance!
These issues can be occurred because lack of permissions for a file try one of the following commands with the proper elevated permissions. For number one, you don't need sudo but if that didn't work try the second one of them should help you
1. psql -h hostname -d databasename -U username -f file.sql
2. sudo -u postgres psql db_name < 'file_path'
I'm trying to dump a .sql file into a PostgresSQL database and it's acting kinda funky. I've followed a lot of the advice here (Import SQL dump into PostgreSQL database) and thought I got close. Whenever I try something like:
psql -h localhost -d db_name -U postgres -f sql_file.sql
It starts to work, but then I start to get a bunch of errors in a row like
psql:sql_file.sql:42: error: invalid command \'s
psql:sql_file.sql:43: error: invalid command \'t
psql:sql_file.sql:44: error: invalid command \'s
With that final invalid command changing to different strings on the end there. Is it not understanding some escape characters and instead trying to use them as commands in psql? If so, how do I avoid this? Eventually the dump terminated with:
psql:sql_file.sql:2281: error: out of memory
It is a rather large sql file (about 150GB). Am I going about this the wrong way? Any advice?
all I am trying to restore my db from pg_dump that I got from my server. I know there are plenty similar question, I tried what was suggested but still can not resolve my issue.
I created my pg_dump via this command:
pg_dump name_of_database > name_of_backup_file
Then I create new db:
createdb -T template0 restored_database
Then I restore using this command:
psql -1 -f name_of_backup_file.sql restored_database
It runs and then I got different syntax errors, for example:
psql:nurate_pg_dump.sql:505: invalid command \nWatch
Query buffer reset (cleared).
psql:nurate_pg_dump.sql:512: invalid command \nThe
psql:nurate_pg_dump.sql:513: invalid command \N
psql:nurate_pg_dump.sql:4098: ERROR: syntax error at or near "9"
LINE 1: 9 the course is not difficult, but Zauresh Atakhanova is not...
I believe since I made pg_dump from the same server, and try to restore it there nothing changed in my server setup, or version of postgres, so I think my db should restore correctly. How can I resolve these syntax errors?
EDIT: Ok, the problem is not with the syntax:
CREATE EXTENSION
ERROR: must be owner of extension plpgsql
This error is thrown at this line:
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
try to restore your database with
psql restored_database < name_of_backup_file
I work in project of geocoding and I want to import the OpenStreetMaps data. I created a database and named it nominatim and I tried this command:
sudo ./utils/setup.php --osm-file morocco-latest.osm.pbf --all –osm2pgsql-cache 18000 2>&1 | tee setup.log
it shows me this message :
CREATE DB
ERROR: database already exists ( pgsql : // #/nominatim)
After I delete my database nominatim it shows this error message:
ERROR: unable to find /usr/pgsql-9.3/share/contrib/postgis-1.5/postgis.sq
BTW: I installed postgres with all the package.
I have just stumbled on this error and here is how I resolved it.
Edit the file
./utils/setup.php
and comment the following lines.
//array('create-db', '', 0, 1, 0, 0, 'bool', 'Create nominatim db'),
and the whole function where the database is created.
/**if ($aCMDResult['create-db'] || $aCMDResult['all']) {
echo "Create DB\n";
$bDidSomething = true;
$oDB = DB::connect(CONST_Database_DSN, false);
if (!PEAR::isError($oDB)) {
fail('database already exists ('.CONST_Database_DSN.')');
}
passthruCheckReturn('createdb -E UTF-8 -p '.$aDSNInfo['port'].' '.$aDSNInfo['database']);
}**/
If you now run the command, it will skip the db creation and carry out the importing. Once all done remove the comments from the file.
You also can drop nomination database by
sudo -su postgres
dropdb nominatim
just change the database name in the following location
Nominatim/settings/
Edit the database name in this file settings.php.
#define('CONST_Database_DSN', 'pgsql://#/nominatim');
change with your database name
#define('CONST_Database_DSN', 'pgsql://#/nominatimMorocco');
If you change your database name here than you also need to change following nominatim installation command.
./utils/specialphrases.php --countries > specialphrases_countries.sql
psql -d nominatimMorocco -f specialphrases_countries.sql
./utils/specialphrases.php --wiki-import > specialphrases.sql
psql -d nominatimMorocco -f specialphrases.sql