I just downloaded the Postgres.app (9.4.5). I want to load (restore) the example database from http://postgresguide.com/setup/example.html. I can't seem to get it imported.
I opened a psql session via the app, exited back to the shell, created a .bash_profile in my home directory (per http://postgresapp.com/documentation/cli-tools.html), quit terminal and opened a new psql session and exited to the shell once again. I then ran the pg_restore command as shown on the example page. I saved the log, but it is 3K lines long and doesn't show any obvious errors. There is nothing in the pgadmin.log in my home directory.
When I start pgAdmin3, I can find no evidence that the database was loaded.
I'm brand new to Postgres, but experienced with Oracle and MySQL.
This is all I see in pgAdmin3. I created the one table in my schema manually.
Did I overlook something?
The pg_restore command on that page does NOT restore the database. It dumps the contents of the backup to stdout. It needs an additional switch '-d' to import directly into a database. But first you have to create an empty database. You can do that from pgAdmin lets say you call it exampledb then the restore would become:
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d exampledb example.dump
Related
My project is again live no problems whatsoever, but the database is empty.
I am either trying to restore an old backup to the new Postgres instance or upload a backup from my local disk.
I tried to do pg:restore but I don’t know where to grab the backup (from the free Heroku tier).
I got the answer I was looking for by going into some of the most hidden help articles in heroku.
https://help.heroku.com/QG1W7LIJ/how-do-i-restore-a-partial-backup-or-single-table-to-heroku-postgres
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U YOUR_USERNAME-d CONNECTION_URL mydb.dump
Had to recreate the backup from the local imported database but at the end it worked flawlessly.
I'm trying to configure an Oracle Database container. My problem is whenever I'm trying to restart the container, the startup script wants to configure a new database and failing to do so, because there already is a database configured on the specified volume.
What can I do let the container know that I'd like to use my existing database?
The start script is the stock one that I downloaded from the Oracle GitHub:
Link
UPDATE: So apparently, the problem arises when /etc/init.d/oracle-xe-18c start returns that no database has been configured, which triggers the startup script to try and configure one.
UPDATE 2: I tried creating the db without any environment variables passed and after restarting the container, the database is up and running. This is an annoying workaround, but this is the one that seems to work. If you have other ideas, please let me know
I think that you should connect to the linux image with:
docker exec -ti containerid bash
Once there you should check manually for the following:
if $ORACLE_BASE/oradata/$ORACLE_SID exists as it does the script and if $ORACLE_BASE/admin/$ORACLE_SID/adump does not.
Another thing that you should execute manually is
/etc/init.d/oracle-xe-18c start | grep -qc "Oracle Database is not configured
UPDATE AFTER COMMENT=====
I don't have the script but you should run it with bash -x to see what is the script looking for in order to debug what's going on
What makes no sense is that you are saying that $ORACLE_BASE/admin/$ORACLE_SID/adump does not exist but if the docker deployed and you have a database running, the first time the script run it should have created this.
I think I understand the source of the problem from start to finish.
The thing I overlooked in the documentation is that the Express Edition of Oracle Database does not support a SID/PBD other than the default. However, the configuration script (seemingly /etc/init.d/oracle-xe-18c, but not surly) was only partially made with this fact in mind. Which means that if I set the ORACLE_SID and/or ORACLE_PWD environmental variables when installing, the database will be up and running, with 2 suspicious errors, when trying to copy 2 files.
mv: cannot stat '/opt/oracle/product/18c/dbhomeXE/dbs/spfileROPIDB.ora': No such file or directory
mv: cannot stat '/opt/oracle/product/18c/dbhomeXE/dbs/orapwROPIDB': No such file or directory
When stopping and restarting the docker container, I'll get an error message, because the configuration script created folder/file names according to those variables, however, the docker image is built in a way that only supports the default names, causing it to try and reconfigure a new database, but seeing that one already exists.
I hope it makes sense.
I'm reading the documentation here, and I have a few questions. Just to make sure I'm not misunderstanding what this terminal command is supposed to do.
Question 1:
I have an SQLite .db file on my local computer. With this command, I can convert this db into a mydb.dump file, which I can then import into Heroku Postgres. Is this intepretation correct? If so, we can move on to my second question.
Question 2:
Attempting to run PGPASSWORD=mypassword pg_dump -Fc --no-acl --no-owner -h localhost -U myuser mydb > mydb.dump is causing me some issues. From what I can understand, the values I'm supposed to substitute are
mypassword (heroku postgres password)
myuser (I have no idea what's supposed to be here)
mydb (name of db)
mydb.dump (name of dump)
What exactly should go into each of these values, and where can I find them?
The pg_dump command dumps a PostgreSQL database. It has nothing to do with SQLite.
SQLite and PostgreSQL are very different databases. If you're going to use Postgres in production I strongly recommend using it in development as well. In general, your development environment (and any others, like a staging environment) should be as similar as possible to your production environment.
I am having a QA instance which contains a very limited data(approx 30-35 MB) it contains images etc, thumbnails hence cannot put them into seed.
I have a private repo at github(synced with heroku) which contains a .dump file say abc.dump file and I want to run my test cases from travis, in the before script I will be restoring this dump.
I would like to know how to import this dump to heroku although this is available at heroku bash as well. I looked into the documentation here they say make it asseccible through http somewhere. I am trying using the pg_restore commands using the database username, passwords available at the application database overview available through UI, but not working.
Can someone suggest me a good way out to simply restore by not making my database public ?
Also. how often the database user/password is changed at heroku ?
As travis would be having access to abc.dump beforehand it can perform basic pg_restore function of postgresql.
PGPASSWORD=<PASSWORD> pg_restore --verbose --clean --no-acl --no-owner -h <PG_HOSTNAME> -U <PG_USER> -d <PG_DATABASE_NAME> -p <PG_PORT_NO> <DUMP_FILE>.dump
The above details for the heroku database hostname, user, pass, port etc. can be fount easily using :-
heroku pg:credentials DATABASE --app application_name
I have a Postgres permissions problem, every time i brew install postgres it does so as root user resulting in permissions denial on initdb, createdb and or anything else i try.
I sudo chown the ownership of /usr/local/var/postgres and it seems to change and allow me manual entry into the directory from cmd line, which then only consists of a server.log file listing the error:
postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": No such file or directory
I then go to initdb and it returns:
The files belonging to this database system will be owned by user "jamesbkemp".
This user must also own the server process.
The database cluster will be initialized with locale "en_GB.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres"
I then go back to look at /usr/local/var/postgresand the owner has changed back to root. I really am at a loss after many hours on this as to what's going on. Any ideas folks?
Postgresql install as non root is a pain if not impossible, because it was not designed this way: it is a multi-user service.
The same thing here: apache2 as non-root - you would have to build the server yourself changing the configuration a lot.
Let me add that for an experienced datacenter operator this is a strange idea, like driving a race car in your appartment.