My default Postgres (installed via brew) is at v14, and I can't start it because the files are at version 12:
DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 14.0.
I can't upgrade the files:
==> Moving postgresql data back from /usr/local/var/postgres.old to /usr/local/var/postgres...
Error: Failure while executing; `/usr/local/opt/postgresql/bin/initdb --lc-collate=C --lc-ctype=C --lc-messages=C --lc-monetary=C --lc-numeric=C --lc-time=C -E\ UTF8 /usr/local/var/postgres` exited with 1.
There is also this error when I do brew services:
postgresql error /usr/local/opt/postgresql/homebrew.mxcl.postgresql.plist
I have version #12 installed but when I open it I can't see the databases in my default install.
What is the best path forward to resolve this?
On your postgres 12 set the folder where the data you need (or a copy of this folder) as the working folder for postgres 12. Do pgdump on this version and then pg_restore on postgres 14.
Use the next link to identify the working folder:
Where does PostgreSQL store the database?
Related
I'm using a Linux server, I want to upgrade postgresql from the version 9 to 11. I have created a dump of my database. Then I have installed postgresql 11, now I want to import the dump to postgresql 11, I run the command
pg_restore -h localhost -d dbLitstUsers -U postgres .dataBasebackup but get the error
pg_restore: [archiver] unsupported version (1.14) in file header
How can I fix this error ?
You must have used a pg_dump from v12 or higher. That generates a custom dump in a format (1.14) which is not compatible with older pg_restore. Retake the dump with the pg_dump coming with the version you want to restore to.
I have the package postgresql11-contrib installed.
$ yum list installed | grep contrib
postgresql11-contrib.x86_64 11.11-1PGDG.rhel7 #pgdg11
Here is the version of postgres.
psql (PostgreSQL) 11.6
I have the below entries in postgresql.conf which is causing the error.
shared_preload_libraries = 'pg_stat_statements' # (change requires restart)
pg_stat_statements.max = 10000
pg_stat_statements.track = all
Upon some online searching I found that, I need to run "Run CREATE EXTENSION pg_stat_statements in the database(s) of my choice". But to do that I first commented above mentioned 3 lines from conf file because my psql server was failing to start with error could not access file "pg_stat_statements": No such file or directory".
https://www.oreilly.com/library/view/mastering-postgresql-11/9781789537819/a6a44124-558b-42f9-a0f3-eb52ea2799d4.xhtml
https://www.postgresql.org/docs/11/pgstatstatements.html
Now when I execute the command CREATE EXTENSION pg_stat_statements; I see error "could not open extension control file "/usr/postgresql/share/extension/pg_stat_statements.control": No such file or directory" and upon looking into the mentioned directory, these is no file pg_stat_statements.control
What am I missing here? Please help.
You seem to have installed two versions of Postgres on your Redhat/CentOS machine.
You probably have installed postgresql11 from the PGDG repository (yum.postgresql.org) as well as the default postgresql provided by CentOS 7. If you do rpm -aq | grep postgres I'll bet you'll see a v. 11 and a v. 9.2.
Just yum erase postgresql, which will delete the v. 9.2 instance that's in the CentOS repository. However, before you do that you'll need to dump the database(s) and stop Postgres. After you delete v. 9.2, you'll need to do a fresh initdb before starting Postgres, and re-load the data you had dumped.
This is a local setup on macOS with homebrew installed postgresql (12.1) and postgis (3.0.0).
I am getting this error in some java integration test:
Caused by: org.postgresql.util.PSQLException: ERROR: could not access file "$libdir/postgis-2.5": No such file or directory
and therefore tried to update the extension which caused another error:
# ALTER EXTENSION postgis UPDATE;
ERROR: syntax error at or near "SUPPORT"
I couldn't find anything about this particular error message.
After trying some downgrades of postgresql and postgit, I asked in irc.freenode.net#postgis and was told to check my postgresql version (psql --version or SELECT version(); also shown on psql startup) and lo and behold the server version was still 11.5 while the client was 12.1.
Turned out I didn't upgrade the database and restart the homebrew managed postgresql service after the last brew upgrade. The following steps got me to the 12.1 version of the server as well:
$ brew services stop postgresql
$ brew postgresql-upgrade-database
$ brew services start postgresql
Which allowed me to update the postgis extension successfully afterwards:
ALTER EXTENSION postgis UPDATE;
I work with PostgreSql and PgAdmin, and I have had an accident that drives to format my Mac, here I have two options, recover all system via TimeMahine or install all from zero.
I have chosen install from zero, but I need to recover the old PostgreSql database, now I’m installing all again, pgAdmin… etc, but I don’t have any backup of my old database, I have the old PostgreSql database system files (thanks to TimeMachine),
How can I recover the old database to the new one?
I tried to do this, from http://www.postgresql.org/docs/8.1/static/backup-file.html
tar -cf backup.tar /usr/local/pgsql/data
the problem is that the data files are (I think) in /Library/PostgreSQL/9.1/data and the folder is encrypted or hidden ¿?
and I can't execute tar command this is what happens:
tar -cf backup.tar "/Volumes/backup/Backups.backupdb/MacBook, MacBook Pro de Albert/2014-04-30-112220/Macintosh HD/Library/PostgreSQL/9.1/data"
I get this error:
tar: /Volumes/backup/Backups.backupdb/MacBook, MacBook Pro de Albert/2014-04-30-112220/Macintosh HD/Library/PostgreSQL/9.1/data: Cannot stat: No such file or directory
tar: Error exit delayed from previous errors.
Another option was to copy the TimeMachine folder /9.1/ beside the new 9.3 and try this:
How to restore a file system level copy of a PostgreSQL database (not dump) to a different PC
but when executing pg_dump asked me a pasword I didn't had.
The solution for dummies: Uninstall pgAdmin 9.3, and install pgAdmin 9.1, here detects the folder 9.1 and tell me It was going to use it ¡perfect! it is exactly what I need.
Now I can keep 9.1 or upgrade to 9.3
I'm having trouble starting postgres as you can see below:
$ pg_ctl -D /usr/local/var/postgres start
server starting
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.1, which is not compatible with this version 9.3.0.
Anyone know how to make the versions compatible?
You have two choices:
Run 9.1 version, dump your database and restore it using 9.3
http://www.postgresql.org/docs/9.3/static/pgupgrade.html