Can I install postgresql without pgAdmin4? - postgresql

I was packaging an windows application installer by NSIS.
An postgresql binary file was included in this install package.
But the official binary file is too large 172MB.
The zip archive is download from
https://www.enterprisedb.com/download-postgresql-binaries
The inside structure is like
pgsql
bin
doc
include
lib
pgAdmin4
share
StackBuilder
symbols
In my opinion, pgAdmin4 is no need for my installer.
There are only CRUD operations in between application and SQL.
If I remove this directory, the binary zip can down to 41MB.
So could I simply remove directory pgAdmin4 and re-compress
to achieve this?

So could I simply remove directory pgAdmin4 and re-compress to achieve this?
Yes, and you can remove StackBuilder too if you want. Also symbols if you don't want to do in-place debugging if the postgres server crashes.
Please, please install your bundled PostgreSQL on a non-default port (not 5432) and if you run it as a service use a name associated with your application, so users know where it came from. See Installation of postgresql with NSIS . Put the PostgreSQL install directory within your app install directory.

Related

Postgres: PostGIS extension in a separate path

The Linux machine I use has SuSE 12.1 with Postgres 9.4 installed (as root). I was able to compile and install the PostGIS 2.5 extension in a user area. Under this installation, I see, among other things, contrib folder, some sql files and .so files etc.
I can launch Postgres using my personal user. How can I let Postgres know to refer to this directory where all the PostGIS extension related files/objects are available?
When I try creating the extension, I get the following error:
ERROR: could not open extension control file "/usr/share/postgresql94/extension/postgis.control": No such file or directory
Of course, some error is expected as Postgres doesn't know about my PostGIS installation. But the latter does not have such a file, postgis.control.
I am guessing the solution is to ensure Postgres can see the .so files (may be set LD_LIBRARY_PATH?) or create a postgis.control file with all the relevant details etc.
Any assistance including simply pointing to documentation will be appreciated.
I see a few similar questions but no one seems to address my issue of the extension - PostGIS - in a separate directory. They assume root access.
Like every extension, PostGIS has to be installed in the PostgreSQL extension subdirectory (under share).
When PostGIS is configured, it looks for pg_config on the PATH, or you can explicitly specify the --with-pgconfig option to configure.
Once you have built PostGIS, make install will automatically put all files in the proper place.
You are not very specific how you built PostGIS, but you must have strayed from the correct path somewhere. If you share some details, we might be able to figure out what went wrong.
Re-reading your question I get the impression that you installed PostGIS somewhere outside the PostgreSQL software directory because you lack the necessary root privilege. That simply won't work, and there is no workaround.
You'd have to install PostgreSQL somewhere where you have write access.

Does Postgresql work after copied to other directory on windows?

I'm new to Postgresql and am going to install on A directory for my Application.
After building a package including the Application and Postgresql, I should deliver it to other user(by Installer but Postresql is not embedded).
I was wondering if it is okay for me to just copy Postgresql to other directory without any consideration of registry or environment variables on Windows.
Does it work by copying the all of directories to other directory or server?
If you stop the running PostgreSQL service, and you preserve file permissions when copying/moving, and the destination is also a NTFS filesystem, it will work. But you'll have to adjust the service definition or create a new one to start from the new location; PostgreSQL won't know where the data directory is until you tell it.
However.
You should simply initdb PostgreSQL where it needs to be in the first place. There's no need to copy or move the data directory. Ask the user where they want it to be put and then put it there from the start.
I strongly recommend that you bundle PostgreSQL binaries in your installer rather than having the user run a PostgreSQL installer first. Then have your app initdb its own private PostgreSQL data directory for its use.
See Installation of postgresql with NSIS (it doesn't matter if you're not using NSIS, the principles are the same).

postgresql client library for Lazarus Pascal - missing libpq.dll error

I'm trying to create my first application with Lazarus Pascal and PostgreSQL.
The pg database is on my Ubuntu Linux host. Lazarus is on XP, running through VirtualBox.
When trying to make a connection to the PG database, I get an error that libpq.dll is missing.
What should I do? Pretty new to this platform.
From the docs here http://wiki.lazarus.freepascal.org/postgres
Error: "Can not load PostgreSQL client library "libpq.dll""
The program cannot find your PostgreSQL driver files. Copy all required PostgreSQL .dll/.manifest files either
to your project directory and your executable output directory,
or to a directory in your search path (e.g. c:\windows\system32)
A good example that demonstrates how to include drive DLL files when connecting Lazarus with PostgreSQL under Windows is easyDB.
On Linux/Unix/OSX: make sure the PostgreSQL libraries are in your library search path, e.g.:
On linux add the path to the libpq.so file to the libraries section in your /etc/fpc.cfg file. For example : -Fl/usr/local/pgsql/lib
It may be necessary to create a symbolic link from a specific library version to a general library name:
ln -s /usr/lib/pqsql.so.5 /usr/lib/pqsql.so
. Alternatively, install the postgresql client -dev package using your distribution's package manager

"existing data directory" error when installing PostreSQL for mac

Hey guys i have been trying to download it from the below link
http://www.enterprisedb.com/products-services-training/pgdownload
But once i download it, and try to run the set up it is giving me an error saying
An existing data directory has been selected but its neither empty, or a recognizable date directory,I tried changing the path on which it has to be downloaded it is not letting me do so
I'd recommend trying a package manager such as brew. Once you have it installed simply:
brew install postgres
Disclaimer: I have no experience with Postgres on Mac (or with a Mac at all).
The installer will create a directory where PostgreSQL stores all the database data and information. Without this so called "data directory" PostgreSQL does not work.
This data directory has nothing to do with your download directory.
Apparently you are pointing the installer to a directory that already exists and contains some data (not necessarily Postgres related data).
When being prompted for the "data directory" during installation you have to select an empty directory.
I don't know if the selection dialog of the installer will let you create a new directory, so you might want to create that directory manually before starting the installer.
Recently had this issue after attempting a reinstall of PostgreSQL on macOS 11.6
Removing the contents of the /Library/PostgreSQL/14/data directory seemed to resolve the issue and was able to successfully reinstall

Where do I get libpq source?

I want to write application which uses Postgresql as DBMS.
To write client application do I need libpq library and header files?
If yes where I would get libpq library and header files.
Libpq is included in the full PostgreSQL source code. You can use just libpq without the rest of PostgreSQL, but must download the full package.
You can download it from the PostgreSQL Downloads page.
Once you extract the full package it is inside src\interfaces\libpq.
The PostgreSQL installation guide details how to install only the client libraries in the Installation section, under Client-only installation.
Libpq documentation is also available.
In postgresql sources, src\interfaces\libpq.
And yes, it is possible to compile only the libpq.
get the lipq from repo, {for debian} :
sudo apt-get install libpq-dev
I was also facing this issue but didn't got a clear answer:
This issue clearly states that while installing diesel-cli system is not able to locate libpq.lib
First of all you should have a Postgres installed on your machine.
Also diesel require visual c++, thus download and install it if not already, the size of setup will be ~5gb.
Once above installations are done you need to setup environment variables:
In my case path of Postgres installation is C:\Program Files\PostgreSQL thus add 2 environment variable path under User variables add new in Path where your libpq.lib is located in my case it is available in both C:\Program Files\PostgreSQL\12\lib and C:\Program Files\PostgreSQL\12\bin
Once this is added create one more environment variable PQ_LIB_DIR and set path as shown below
Note: Once done re-trigger the installation command in a new cmd window
Source: pq-sys and github-solution
For Windows users, it's in (version may be different)
C:\Program Files\PostgreSQL\11\lib
There you find libpq.lib. Provide this directory to Linker input.
Don't forget to include C:\Program Files\PostgreSQL\11\include directory for include directories.
I fix this problem reccently. This is a solution if you don't want to install Postgres in you windows.
At first, you need download Postgres Binaries. The version I download is 13.6, but it's seems like any version is fine.
Unzip the zip file.Copy libpq.lib from pgsql\lib to shomewhere like C:\Program Files\Postgres\lib.
Execute the following command in cmd window.
setx PQ_LIB_DIR "{where_you_copy_to}"
Open a new cmd windows and install diesel_cli
cargo install diesel_cli --no-default-features --features postgres
In linux vertify you get the libpq.
1st, there is an app: pg_config: https://www.postgresql.org/docs/current/app-pgconfig.html
after you found out the pg_config absolute bin path.(if you installed multi version of postgressql) Then You can get
--includedir
Print the location of C header files of the client interfaces.
--libdir
Print the location of object code libraries.
Then try to compile/build some example code: https://www.postgresql.org/docs/current/libpq-example.html
Some common failure example: https://www.postgresql.org/docs/current/libpq-build.html
You can install Postgres locally from https://www.enterprisedb.com/downloads/postgres-postgresql-downloads but select only "Command line tools" for install.
After that, you can found libpq.dll in C:\Program Files\PostgreSQL\15\bin