How to install postgresql-client / psql on Nixos - postgresql

I'm wondering how to install the psql command on NixOS. To be clear: I'm only interested in the client, not the server.
I've looked at the derivation but couldn't find any pointers.
Is there a way to create a derivation without building from source?
Thanks!

The psql command is in any of the postgresql* packages, so you can just add that to environment.systemPackages and rebuild:
environment.systemPackages = [ pkgs.postgresql ];

Instead of installing the package you can also use nix shell / run, and define a shell alias:
alias psql="nix shell nixpkgs#postgresql --command psql"

Related

How to run pg_ctlcluster with CentOS?

I'm using CentOS 7 with EPEL Repo and installed Postgresql 9.6 which is a need for a webshop application. Now some propel installation script wants to execute pg_ctlcluster. The Installation ends with an error:
Exception: sudo: pg_ctlcluster: command not found
I checked /usr/pgsql-9.6/bin, there is only pg_ctl, but no pg_ctlcluster. Some said pg_ctl and pg_ctlcluster are not exactly the same. It looks like pg_ctlcluster is a Ubuntu thing. It's used for Postgres Cluster (...).
Do you have any ideas what's the best way to replace pg_ctlcluster?
Just copy/symlink pg_ctlcluster -> pg_ctl sounds not like it should be. Maybe someone have a suiteable RPM.
pg_ctlcluster is not part of core PostgreSQL, but the PGDG Debian install packages come with an additional utility command of that name.
So that propel installation script is written for Debian or Ubuntu Linux.
You'd best ask the provider of the script for a script that supports the Redhat-based Linux distrubutions.
I didnt want to overwork the whole PHP installation script, so this fix worked for me:
- $process = $this->getProcess(sprintf('sudo pg_ctlcluster %s main restart --force', $postgresVersion));
+ $process = $this->getProcess(sprintf('sudo -i -u postgres /usr/pgsql-9.6/bin/pg_ctl %s restart', NULL));
+ $process = $this->getProcess(sprintf('exit', NULL));
Not for use in productional enviroments

Running PostgreSQL commands from anywhere on the terminal

First off, let me say that I'm new to both using Mac and PostgreSQL. I just installed Postgres using their installer and it was installed in /Library/Postgres/... when I tried running createdb from the terminal it returned an error createdb: command not found. I ended up using /library/postgresql/9.6/bin/createdb before I coud get it to work.
Here's my question, how do I set it so that I don't have to type in the full path again to use the createdb command.
I'd love a detailed explanation.
Thanks
First you need to execute the psql command to get into the postgresql interacive shell.
In your terminal:
psql
Postgresql interactive shell should start. In this shell
> createdb yourdatabasename;
Btw: If psql is not found you will probably need to add it to your path and restart your terminal, something like this with the path matching your machine:
export PATH=/Library/PostgreSQL/9.5/bin:$PATH

pgbench for postgresql 9.3 for centos where to find it?

How can I install pgbench for postgresql 9.3?
I have basically set up my postgresql9.3 on centos 64 bit, and it runs fine. No problem at all.
I then installed postgresql93-contrib on my centos machine. But i dont seem to have pgbench? I get command not found?
I execute the following under bash:
pgbench -i -U test test
any ideas?
It is in contrib. The exact spelling depends on which repo you use, something like postgresql93-contrib
It is possible that pgbench will not be in your default path. Then you can run it by executing: /usr/pgsql-10/bin/pgbench --help
in Centos6
install pgbench
yum install postgresql93-contrib
then pgbench will appear in /usr/pgsql-9.3/bin
add this path to system
vi /etc/profile
add /usr/pgsql-9.3/bin to Path
source /etc/profile
now can run pgbench now

AWS EC2 and rvm ssh

I have created user for my AWS ec2 VPS (deployer)
When i am logging with:
ssh -i ~/.ssh/aws/*...*.pem ubuntu#ec2*...*.amazonaws.com
command rvm use 2.0.0 is working correctly
=>
ubuntu#ip-***:~$ rvm list
rvm rubies
=* ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
ubuntu#ip-***:~$ rvm which
ubuntu#ip-***:~$
But when i use su - deployer i have got:
deployer#ip***:/home/ubuntu$ rvm
The program 'rvm' is currently not installed. You can install it by typing:
sudo apt-get install ruby-rvm
I would like to understand how correctly write command for ssh login.
I have tried:
ssh -i ~/.ssh/aws/*.pem *ubuntu#ec2***.amazonaws.com -t 'bash --login -c "rvm"'
but received "Connection to ec2-*.amazonaws.com closed".
Within my local machine rvm functioning correctly. I have added
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
into my ~/.bash_profile
I have spent 3-5 hours studying stackoverflow topics related to this issue, but still not understand what am i doing wrong.
Any help will be highly appreciated! Thanks in advance!
I've run into this problem before and there are 2 ways to solve it.
The first way is to log in directly as the deployer user to the instance. This might mean having to create a ssh keypair (see ssh-keygen -t rsa). Then you can log in with ssh deployer#ec2.instance.address This way the rvm will be loaded directly to the deployed user's shell.
A second way is not to use the dash when su to the deployed user account.
When you use the dash then you load your own bashrc vs that particular user's bashrc.
So sudo su deployer
you nee to use:
su - deployer
it will ensure you use login shell

How do I uninstall the uuid_ossp module in postgresql 9.0.4?

I used the following command to install the postgres UUID_OSSP module in version 9.0.4 :
$psql -d <database> -U <user> -f <path to>/uuid-ossp.sql
How do I uninstall this? I am exporting this database and I don't want this to show up in the DB export script. I'm no longer using the module. I found a lot of answers related to installation of this module but not uninstallation.
Thanks in advance
There should be a uninstall_uuid-ossp.sql script in the same directory where uuid-ossp.sql is located.