I am trying to import an old .gz database dump into my database using the terminal. It is a Postgresql environment.
This is what i am doing:
psql test < 052710_1.gz
Responce:
ERROR: syntax error at or near "test"
LINE 1: test
^
I also tried:
psql --dbname test < --file 052710_1.gz
psql -d test -U postgres -f 052710_1.gz
And they both gave me the same error.
I have tried using the .exe on the end of psql and it has the same issue.
I am running Postgresql 10.1
For the case of version 10.1
try using the following command
pg_restore -d test < 052710_1.gz
Hope this works.
Please follow the commands. Hope it will works.
sudo psql -U postgres
create database temp_databse;
exit
Execute following command
psql -U postgres temp_database < extracted_database_file_name
Above command will restore database...
Related
I got error 2 when exec sql file by dictionary
I tried to exec mysql file on Mac OS at this dictionary: "/Users/kato/Desktop/world_mysql_script.sql"
source /Users/kato/Desktop/world_mysql_script.sql;
Then I got this error:
Failed to open file '/Users/kato/Desktop/world_mysql_script.sql', error: 2
Do you have any solution?
1.
Please try to use mysql command.
mysql -u DB_USER -p -h DB_HOST DB_NAME < /Users/kato/Desktop/world_mysql_script.sql
I want to create structure.sql of existing schema. but getting same error while executing db:structure:dump
No such file or directory - pg_dump -i -s -x -O -f F:/Workspace/TestApp/db/structure.sql db_name
I tried deleting schema.rb and chnages schema format to :sql, But it did not work either.
How to deal with this?
Got the issue...
I just have to add postgres to PATH env variable, after that it worked..
I work with PostgreSQL 9.2 and bash script. I have a problem.
My DB is TestDB ,
Table name is config
and my bash code is
sudo -u postgres psql -c "select count(*) from public.config where var_name='url'"
result is
ERROR: relation "public.config" does not exist
Can anybody help me?
sudo -u postgres psql TestDB -c "select count(*) from config where var_name='url'
The Database was missing, so you executed the command into postgres db where you probably don't have that table ;-)
Im trying to do a postgresql base back up via bash chef resources. Below is my code and im getting the following error. When i deploy them. Any thoughts why.
$PGDATA = "node['fc_db']['postgres']['pg_data']"
bash "backup master db" do
user "postgres"
code <<-EOH
initdb –D –-no-locale –-encoding=UTF8
pg_ctl –D #{$PGDATA} start
psql –c "SELECT pg_start_backup('initial backup for SR')" template1
tar cvf pg_base_backup.tar #{$PGDATA}
psql –c "SELECT pg_stop_backup()" template1
EOH
end
Which version of Ruby are you using? If not 2.x.x, try adding # encoding: UTF-8 on top of your wal-e.rb?
The line in the code :
initdb –D –-no-locale –-encoding=UTF8
Should be:
initdb –D --no-locale --encoding=UTF8
so I have can create a dump
/Applications/MAMP/Library/bin/mysqldump -u admin -p testsite > yourdump.sql
but how do I run this on another mac in terminal?
I should be as simple as running this:
mysql -u<user> -p dbName < db_backup.dump