

- #Postgres app data directory how to#
- #Postgres app data directory update#
- #Postgres app data directory upgrade#
- #Postgres app data directory password#
- #Postgres app data directory Pc#
Once you opened the file, search for the string data_directory and change it to: /mnt/new_volume/postgresql/9.6/main Open the file /etc/postgresql/9.6/main/nf (check your current postgres version for the correct path).
#Postgres app data directory how to#
Step 2: How to change postgreSQL configuration to a new data pathĪll postgreSQL configuration are in the /etc/postgresql path. We use -a flag on rsync to preserve the permissions and other directory properties and -v is to show verbose output. sudo rsync -av /var/lib/postgresql /mnt/new_volume IMPORTANT Be sure there is no trailing slash on the directory. Remeber to change /mnt/new_volume to match your new directory. This tool is used to make remote and local file synchronizarion. Now in order to move the files stop postgresql: sudo systemctl stop postgresql In our case the printed directory was: /var/lib/postgresql/9.5/main This will output the current directory where all the data is currently stored/ On the sql command propt enter the following query: SHOW data_directory You can use your user in case you configured postgresql to allow login with another user.

Step 1: Moving the current data to a new directoryįist change your user to the postgres user and execute psql command. This tutorial is based on Linux, but with some minor changes can be done on OSX. If this is your first postgresql configuration you can skip step 1. We are going to move the current data to a new directory. Now that the database user was created successfully, I can simply log into PostgreSQL using Postico and manage my database(s).WARNING make sure you backup (and also test the backup!) before following the steps detailed in this tutorial. I use Postico for managing my Postgres databases - I personally love the simple and intuitive layout. Once you’re done assigning roles, you can go on with your day-to-day database activity. There are other types of roles and you can assign a user multiple roles. What we’ve done is simply give the created user the ability to create a database. Let’s proceed to assign the user a role, we do that with the command: ALTER ROLE username CREATEDB With the user created, you should be able to log into Postgres now with your credentials.Īt this time, the only action we can perform is to log in, because no role has been assigned to the created user. Remember to add the semi-colon at the end of the command, Postgres can act weird at times when the semi-colon isn’t there.
#Postgres app data directory password#
We can then proceed to create a new user with the command CREATE ROLE username WITH LOGIN PASSWORD 'quoted password'
#Postgres app data directory update#
UPDATE Found an easier fix that might work for you, check it out here: $ postgres -D /usr/local/var/postgres $ rm -rf /usr/local/var/postgres & initdb /usr/local/var/postgres -E utf8 # Then start the server: $ pg_ctl -D /usr/local/var/postgres -l logfile start (the minor difference I think)

So I resolve to reset my PostgreSQL database because I don’t really mind losing the data.Īlbeit if you would like to do this quickly with a three-liner and you’re fine with using the default Postgres user, here’s a quick solution- proposed to me by Dawuda Ebenezer. Usually, I don’t have production data or any important database on my PC, I instead have a back up for large dataset I use for testing.

#Postgres app data directory Pc#
Here’s what the logs look like on my PC at the time of writing: 19:15:41.691 WAT FATAL: database files are incompatible with server 19:15:41.691 WAT DETAIL: The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.1. This command outputs the logs and you should see the cause of the issue. To confirm what the problem is I advise you use this command: postgres -D /usr/local/var/postgres
#Postgres app data directory upgrade#
When this upgrade occurs, your Postgres config file is usually not compatible with the new one. This issue can be caused by a number of things but usually, it’s when you run brew update and you upgrade your Postgres version that this problem comes up. Today, that changes, I’m going to write about it so I can always come back and check it whenever I run into this problem again. I end up restarting my PC a number of times and having to stack overflow it over and over again. I’ve solved this quite a number of times but I usually never remember how I resolve it the next time I encounter it. I’ve been using a MacBook for about 2 years now and I honestly can’t count the number of times I’ve encountered this weird Postgres bug: psql: could not connect to server: Connection refused Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
