I forgot to configure login Email id and password while install pg admin 4. how i can change after installation - postgresql

I am new to pgAdmin 4. I have forgot to setup of login Email id and password while install pgAdmin 4. How can I change after installation? Any one can help me?

I'm assuming that since you don't remember your admin/password, you didn't do much with pgAdmin yet. If that's the case, you can move/remove the SQLite database out of the way and restart pgAdmin:
rm /var/lib/pgadmin/pgadmin4-server.db
or
mv /var/lib/pgadmin/pgadmin4-server.db /tmp
When you do this, you'll be prompted for a password the next time you start up the app.
You can also dump the contents of the SQLite database before moving/removing:
sqlite3 /var/lib/pgadmin/pgadmin4-server.db .dump

As my friend #Almadani and #richyen post are completely right.
But If you are working on remote host databases its best to delete that folder.Such as it may on some instance[ssh]
sudo rm -rf /var/lib/pgadmin
After deletion of folder. you can simply create new credentials
sudo /usr/pgadmin4/bin/setup-web.sh
You can also check it out from the blog.
By the way the blog is from here.

I solved this issue on Linux Fedora 32, and it's working. I hope you find it useful for you.
cd /var/lib/pgadmin4/
[root#localhost pgadmin4]# ls
pgadmin4.db sessions storage
[root#localhost pgadmin4]# rm pgadmin4.db
rm: remove regular file 'pgadmin4.db'? y
[root#localhost pgadmin4]# ls
sessions storage

there is still a way to find the database pgadmin4.db download and open this file via HeidiSQL as SQLite, directly viewing the table is not available - you can run the query SELECT * from user you will see your username, and if you do not remember the password can be changed to any known (encoded) - this method helped me

It was solved with me by removing pgadmin4.db, and run
python3.6 /usr/lib/python3.6/site-packages/pgadmin4-web/setup.py
and restart Apache web server, pgadmin4.

Related

docker-compose pull gives either a gpg error or a permissions error when I attempt to use it with or without sudo

everyone.
I hope that someone can help to answer my question.
I am joining a project in which I have to use various docker containers. I was told that I just needed to use docker-compose to pull down all the necessary containers. I tried this, and got two different errors, based on whether I used sudo or not. My machine is Ubuntu bionic beaver 18.04.4LTS
I have docker-engine installed according to the installation instructions for Bionic on the github page, and docker-compose is likewise installed according to its instructions. I did not create a "docker" group since I have sudo access.
We have two repos that I have to log in to before I can do anything. In order to prevent my passwords from being stored unencrypted in config.json, I followed this guide to set up a secure credential store:
https://www.techrepublic.com/article/how-to-setup-secure-credential-storage-for-docker/
However, rather than asking me for the password and/or passphrase mentioned in this article, the login process makes me enter the actual passwords to the repos. So, the secure credential store may not be working, which might be causing the problem.
At any rate, once I log in and the two commands show login succeeded, I then try to do a
docker-compose pull
on the repos. When I do
sudo docker-compose pull
I get this final error:
docker.errors.DockerException: Credentials store error: StoreError('Credentials store docker-credential-pass exited with "exit status 2: gpg: WARNING: unsafe ownership on homedir '/home/myuser/.gnupg'\ngpg: decryption failed: No secret key".')
an ls of the .gnupg directory is
myuser#myhost$ ls -lA ~ | grep gnupg
drwx------ 4 myuser myuser 226 Feb 9 13:35 .gnupg
gpg --list-secret-keys shows my keypair when I run it as myuser.
I am assuming that what is happening is that because I am running as sudo the user trying to access this directory is root, not myuser, and so it is failing. However, if I leave off the sudo
docker-compose pull
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', PermissionError(13, 'Permission denied'))
I am guessing that this is because my normal user doesn't have the ability to connect to the docker daemon's Unix socket.
So, how do I make these play together? Is the answer to add a docker group so that the command still runs as myuser and not as root? or is there another way to do this?
Also, why is my credential store not asking me for the password set by docker-credential-pass or the GPG passphrase? I suspect these two are related. Perhaps the pull is trying to send my authentication tokens over again and can't because it doesn't have access to the secure credentials store.
All of the above are guesses. Does anyone know what is going on here?
Thanking you in advance,
Brad
I just wanted to follow up with a solution to this question that worked for me.
Firstly, you need to add your user to the docker group that was created during docker-engine's installation.
sudo usermod --append --groups docker your_user_name
Because I had already used sudo to try this, there were a few files that ended up being created by root.
So, you have to chown a few things.
sudo chown your_user_name:your_group_name ~/.docker/config.json
Note that for the group name I used
docker
but I'm not sure if that's necessary.
Then, there were files inside the ~/.password-store directory that needed to be changed.
sudo chown -R your_user_name:your_group_name ~/.password-store
Most of these files are already owned by you, but the recorded credentials are not.
Then, the magic that fixed it all. From
https://ask.csdn.net/questions/5153956
you have to do this.
export GPG_TTY=$(tty)
and it is this last that makes gpg work.
Then, you can log in to your repos if you have to without using sudo
docker login -u repo_user_name your_repo_host
and then log in with your repo password.
Note that I don't know why you have to use the repo password instead of using the stored credentials.
Once you log in, you should be able to do a
docker-compose pull
without sudo
from the directory where you want the containers to be placed.
Note that you will probably have to provide your GPG passphrase at first. I'm not sure about this because I had already unlocked the key by following the steps in the above link to check to see if docker-credential-pass had the right credential store password stored.
and that should do it.

Tables could not be fetched - Error loading schema content

I open workbench and connect to a local database on XAMPP and when open the connection the schema show the error message:
"tables could not be fetched"
run this command on terminal
mysql_upgrade -u root -p
Run this command on terminal
sudo /opt/lampp/bin/mysql_upgrade
And as per the comment by #jonathan-delean , you might need to run this instead:
sudo /opt/lampp/bin/mysql_upgrade -u root -p
For XAMPP, this worked for me - run this on terminal:
sudo /Applications/XAMPP/xamppfiles/bin/mysql_upgrade
Disconnect then reconnect to your db.
First, locate the directory of which Xampp is installed at.
In linux you can just type this in a terminal:
whereis xampp
In my case (btw I use arch, jk) it was located at /opt/lampp/bin . If you're using windows, you may find it under a different location, like in C:\Program Files\xampp\bin
Next, locate the file mysql_upgrade and execute it as an administrator or a sudo.
If you're using Linux:
cd /opt/lampp/bin then sudo ./mysql_upgrade
According to MySQL documentation:
Each time you upgrade MySQL, you should execute mysql_upgrade, which
looks for incompatibilities with the upgraded MySQL server: It
upgrades the system tables in the mysql schema so that you can take
advantage of new privileges or capabilities that might have been
added. It upgrades the Performance Schema, INFORMATION_SCHEMA, and sys
schema. It examines user schemas.
So I believe mysql_upgrade should resolve the problem. It worked for me before.
More on mysql_upgrade here:
4.4.5 mysql_upgrade — Check and Upgrade MySQL Tables
That's because the latest XAMPP use MariaDB and MYSQL Workbench is using MYSQL Database, so they are not fully compatible, raising that error for example.You can try to downgrade to some of the previous XAMPP versions.
For MacOS users:
sudo /Applications/XAMPP/bin/mysql_upgrade
I created another Connection in MySQL workbench, and the fetching problem for me was resloved.
I did have this problem today, the reason is:
Error Code: 1356 View 'test.xyz' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
After dropping those view (actually those views) the error was solved.
currently working with MySQL Workbench 8.0.28, and MySQL 8.0.28.
for macOS users run this on terminal:
sudo /Applications/XAMPP/bin/mysql_upgrade
this worked for me
See YouTube video: MySQL 8 - The message "Tables Could Not Be Fetched"
https://www.youtube.com/watch?v=phi6o8B7kKI
Either a table or view or function used in code has been dropped; hence the "...could not be fetched".
this works for me
sudo mysql_upgrade --force
As #Brittany Layne Rapheal says, with that command you can fix the issue, is also recommended to give execution privileges to that file:
So you should run first this command:
sudo chmod +x /Applications/XAMPP/xamppfiles/bin/mysql_upgrade
And then, this:
sudo /Applications/XAMPP/xamppfiles/bin/mysql_upgrade --force
--force is necessary because as the parameter says to force the update (Necessary)

Error when opening pgAdmin 4 on mac

I have installed version 4-1.5, but when opening it, it always shows this error "The application server could not be contacted."
I removed the local directory hidden and resolved:
$ cd ~
$ rm -r .pgadmin/
Note: macOS Sierra (10.12.6) and pgAdmin 4-1.6. Also you are going to loose configuration data like database list tree, et al.
The Databases will remain intact since you are modifying/deleting PgAdmin related data not any of Postgresql itself.
I had the same issue, I fixed it by stopping the service in Postgres app, then start pgAdmin, and then start the Postgres service. I was able to connect it after that. Hope this help.
I had same error, but in my case I use wrong port number for the database
On my system Safari is the problem as it was default browser.
To fix, make Chrome your default browser and try relaunching pgadmin4
OR
Manually fix by
$ cat ~/.pgAdmin4.5704814747986328352.addr
http://127.0.0.1:62631/?key=0ec25e6a-dfe2-483e-9814-b315ea87c3cf
Paste what you get in Chrome

Psql could not connect to server: No such file or directory, 5432 error?

I'm trying to run psql on my Vagrant machine, but I get this error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Note: Vagrant 1.9.2
Box: ubuntu/trusty64, https://atlas.hashicorp.com/ubuntu/boxes/trusty64
EDIT
Commands I've used in order to install and run postgres:
sudo apt-get update
sudo apt-get install postgresql
sudo su postgres
psql -d postgres -U postgres
I've had this same issue, related to the configuration of my pg_hba.conf file (located in /etc/postgresql/9.6/main). Please note that 9.6 is the postgresql version I am using.
The error itself is related to a misconfiguration of postgresql, which causes the server to crash before it starts.
I would suggest following these instructions:
Certify that postgresql service is running, using sudo service postgresql start
Run pg_lsclusters from your terminal
Check what is the cluster you are running, the output should be something like:
Version - Cluster Port Status Owner Data directory
9.6 ------- main -- 5432 online postgres /var/lib/postgresql/9.6/main
Disregard the '---' signs, as they are being used there only for alignment.
The important information are the version and the cluster. You can also check whether the server is running or not in the status column.
Copy the info from the version and the cluster, and use like so:
pg_ctlcluster <version> <cluster> start, so in my case, using version 9.6 and cluster 'main', it would be pg_ctlcluster 9.6 main start
If something is wrong, then postgresql will generate a log, that can be accessed on /var/log/postgresql/postgresql-<version>-main.log, so in my case, the full command would be sudo nano /var/log/postgresql/postgresql-9.6-main.log.
The output should show what is the error.
2017-07-13 16:53:04 BRT [32176-1] LOG: invalid authentication method "all"
2017-07-13 16:53:04 BRT [32176-2] CONTEXT: line 90 of configuration file "/etc/postgresql/9.5/main/pg_hba.conf"
2017-07-13 16:53:04 BRT [32176-3] FATAL: could not load pg_hba.conf
Fix the errors and restart postgresql service through sudo service postgresql restart and it should be fine.
I have searched a lot to find this, credit goes to this post.
Best of luck!
I had the same issue but non of the answers here helped.
How I fixed it (mac)
Try to start postgresql with pg_ctl -D /usr/local/var/postgres start
Look for the Error Message that says something like FATAL: could not open directory "pg_tblspc": No such file or directory.
Create that missing directory mkdir /usr/local/var/postgres/pg_tblspc
Repeat from step one until you created all missing directories
When done and then trying to start postgresql again it might say FATAL: lock file "postmaster.pid" already exists
Delete postmaster.pid: rm /usr/local/var/postgres/postmaster.pid
Start postgres with: pg_ctl -D /usr/local/var/postgres start
Done ✨
These two steps solved it for me on Mac:
rm /usr/local/var/postgres/postmaster.pid
brew services restart postgresql
For M1 Macs:
rm /opt/homebrew/var/postgres/postmaster.pid
brew services restart postgresql
In case you face this issue (reported by #luckyguy73): psql: FATAL: database "postgresql" does not exist
You can run
brew postgresql-upgrade-database
to fix it.
I am just posting this for anyone who is feeling lost and hopeless as I did when I found this question. It seems that sometimes by editing some psotgresql-related config files, one can accidentally change the permissions of the file:
Note how pg_hba.conf belongs to root, and users cannot even read it. This causes postgres to not be able to open this file and therefore not be able to start the server, throwing the error seen in the original question.
By running
sudo chmod +r pg_hba.conf
I was able to make this file once again accessible to the postgres user and then after running
sudo service postgresql start
Was able to get the server running again.
WARNING: This will remove the database
Use command:
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
WARNING: This will remove the database
Within zsh:
rm -rf /usr/local/var/postgres && initdb /usr/local/var/postgres -E utf8
This is the only thing that worked for me after countless hours trouble shooting.
Does the /etc/postgresql/9.6/main/postgresql.conf show that port being assigned? On my default Xubuntu Linux install, mine showed port = 5433 for some reason as best as I can remember, but I did comment out the line in that same file that said listen_addresses = 'localhost' and uncommented the line listen_addresses = '*'. So maybe start and check there. Hope that helps.
This works for me:
pg_ctl -D /usr/local/var/postgresql#9.6 stop;
brew services stop postgresql#9.6;
brew services start postgresql#9.6;
I was able to solve the issue by running:
sudo systemctl start postgresql#9.5-main
In my case Postgres was managed through Homebrew Services (i.e. started via brew services start postgresql#10 Terminal command for the Postgres 10 that I use), and for that setup I had to discover a couple of essential steps to do before I could apply any advice in this thread. So I want to share just that piece as it may help someone who has the same setup.
NOTE: all the commands below are to be run in Terminal.
To give a quick background: After upgrading to macOS Big Sur I discovered that Postgres wasn't working and running psql results in the error mentioned in the original question above. I tried to start Postgres (via the brew services start postgresql#10 command), this resulted in a message Service postgresql#10 already started. If I tried to restart it (via the brew services restart postgresql#10) I got a message that it was stopped and then started successfully. But! This was a misleading message, and I spent quite some time searching for config issues etc. before discovering that the service was not started successfully in reality.
So, the way to investigate this is:
Make sure the service is started by running the brew services start postgresql#10 (the latter argument may be different depending on what your Homebrew package name is e.g. postgresql#12 or plain postgresql).
Run brew services list. This is the command that gives you the true state of the service. In my case it said that Postgres' status is error:
Name Status User Plist
postgresql#10 error Denis /Users/Denis/Library/LaunchAgents/homebrew.mxcl.postgresql#10.plist
redis started Denis /Users/Denis/Library/LaunchAgents/homebrew.mxcl.redis.plist
To investigate further open the config shown in the same command output in Plist column (I used nano /Users/Denis/Library/LaunchAgents/homebrew.mxcl.postgresql#10.plist to check it).
In the config look for the StandardErrorPath key, and open the file located in the value of that key, i.e. in the <string> tag following the key. In my case it was /usr/local/var/log/postgresql#10.log.
Open that log and check the latest error (I used nano /usr/local/var/log/postgresql#10.log and then Alt+/ to go to the end of the file).
Voila. That is the real error to investigate, which you can then look for in the previous answers or google for. I'm not covering the rest here, as the goal of this answer is to show how to find the real error if you use Homebrew Services to run Postgres. (In my case it was the lock file "postmaster.pid" already exists already covered in the previous answers, plus the path to check right in the error message, in my case /usr/local/var/postgresql#10).
In my case it was the lockfile postmaster.id that was not deleted properly during the last system crash that caused the issue. Deleting it with sudo rm /usr/local/var/postgres/postmaster.pid and restarting Postgres solved the problem.
I recommend you should clarify port that postgres.
In my case I didn't know which port postgres was running on.
lsof -i | grep 'post'
then you can know which port is listening.
psql -U postgres -p "port_in_use"
with port option, might be answer. you can use psql.
If non of the above answers are not working for you, then please try this one,
Many people have mentioned many solutions to this problem! But all of them forgot that, the same problem will arise when your disk don't have enough space or the space you are assigned for postgres is full
Check your system storage, if its full free up some space! then restart your postgres by sudo service postgresql restart or do a stop and start sudo service posgresql stop then sudo service postgresql start
This will solve the issue, it solved for me
I occasionally have the same issue but mostly after macOS upgrades. Shutting down and migrating to the new version usually fixes it for me(make changes according to your version). So first upgrade your postgresql
brew services stop postgresql#12
brew services start postgresql#12
brew postgresql-upgrade-database
This is mostly a temporary fix but since I couldn't find a better solution this works for me.
Update: If the issue says that another postmaster is running then try removing it from that location(your postmaster.pid location will be displayed to you)
rm /usr/local/var/postgres/postmaster.pid
Open your database manager and execute this script
update pg_database set datallowconn = 'true' where datname = 'your_database_name';
I had the same error when I create the SQL db in a VM. I had changed the default value of /etc/postgresql/9.3/main/postgresql.conf shared_buffers = 200MB to 75% of my total RAM. Well, I forgot to actually allocate that RAM in the VM. When I gave the command to make a new database, I received the same error.
Powered off, gave the baby its bottle (RAM) and presto, it worked.
The same thing happened to me as I had changed something in the /etc/hosts file. After changing it back to 127.0.0.1 localhost it worked for me.
just reinstall your pgsql with direct version sudo apt-get install postgresql-9.5 (u must remove the package before install new one)
I had similar problems just a while ago. After trying more than 5 suggestions I decided to go back to the basics and start from the beginning. Which meant removing my postgresql installation and following this guide upon re-installing postgresql. https://help.ubuntu.com/lts/serverguide/postgresql.html
Ubuntu 20
This Problem happened to me, as ubuntu pre-installed version of Postgresql-9.6 server was always down and after trying all the above answers it didn't start.
Solution:
I installed another version of Postgresql which is postgresql-13, using this command: sudo apt install postgresql it will install the latest version of postgresql.
I see if the server is online or down using this command: pg_lsclusters if the new version of postgresql is online, we will proceed to remove the old version of postgresql.
we will see all packages that are installed related to postgresql, using this command: dpkg -l | grep postgresql
Remove the old version, which is here postgresql-9.6. Using this command:
sudo apt-get --purge remove postgresql-9.6 postgresql-client-9.6 replace 9.6 with your old version number. Final remaining packages related to the latest Version 13:
Restart your postgresql latest version server, which is here postgresql-13. Using this command: sudo systemctl restart postgresql#13-main replace 13 in the command with your latest version number.
Now, if you try psql command you will get an error related to your user, as in the image:
To Remove the above error, The installation procedure created a user account called postgres that is associated with the default Postgres role, to switch over to the postgres account use this command: sudo -u postgres psql this command will log you into the interactive Postgres session. You can also set your password for this user using this command \password postgres.
Then change the Port to the deafult port of postgresql, which is 5432 as all application will try to connect to postgresql using this port by default, using this command: sudo nano /etc/postgresql/13/main/postgresql.conf, it will open postgresql configuration file, then search for port and change it to 5432. After that you need to restart the server using this command sudo systemctl restart postgresql#13-main. Note, Replace 13 in the command with your latest version.
If you want to create your own User/Role, use this command: sudo -u postgres createuser --interactive. The script will prompt you with some choices, as in the image and based on your responses, it will execute the correct Postgres commands to create a user to your specifications.
Tutorial: For more information on postgresql related commands
I couldn't connect using the psql command and kept getting the error Cannot connect to Server: No such file or directory.
Step 1: Check the status of the Postgres cluster
$ pg_lsclusters
Step 2: Restart the Postgres cluster
$ sudo pg_ctlcluster 12 main start
Make sure to replace 12 with your version of Postgres
Step 3: Check again and connect
$ pg_lsclusters
$ sudo -i -u postgres
$ psql
I got this error when I restored my database from last pg_basebackup backup file. After that when I tried to connect database(psql), I was getting the same error. The error was resolved, when I updated pg_hba.conf file and wherever "peer" authentication was there I replaced that with "md5" and then restarted postgres services. After that, the problem was resolved.
This error happened to me after my mac mini got un-plugged (so forced shutdown), and all I had to do to fix it was restart
I have the same issue with postgres 11 on my mac. I get this error every time after restart
psql: could not connect to server: No such file or directory
Is the server running locally and accepting connections on
Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
As a temporary fix I do
brew services stop postgresql#11
brew services start postgresql#11
My problem happened after a brew update so I've ran
pg_ctl -D /usr/local/var/postgres start
and I've got this result:
FATAL: database files are incompatible with server 2021-07-07 13:27:21.692 CEST [70896] DETAIL: The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.2. stopped waiting
I've ran
brew postgresql-upgrade-database
FATAL: could not load server certificate file "/etc/ssl/certs/ssl-cert-snakeoil.pem": No such file or directory
LOG: database system is shut down
pg_ctl: could not start server
I have a missing ssl-cert-snakeoil.pem file so i created it using make-ssl-cert generate-default-snakeoil --force-overwrite And it worked fine.
In my case, I had to run journalctl -xe, and it showed that my disk was full. I then deleted some .gz items from /var/log and I could again restart the postgresql.
I'm on Kali Linux. I had to remove the brew version of postgresql with
brew uninstall postgresql
sudo -u postgres psql got me into root postgres
Simply running these commands from the installation steps in the official PostgreSQL docs worked for me (I'm on Fedora 33):
# Optionally initialize the database and enable automatic start:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13
RHEL Installation link
kali users pls do this
sudo service postgresql restart

PostgreSQL deleted user postgres on accident

Cannot find any tutorials that show what you do when you deleted default postgres user through root.
Created local postgres server through sudo apt-get install postgresql postgresql-contrib. Inside shell, typed psql and was able to initiate db.
Logged into root and deleted postgres account in linux while trying something out.
2a: sudo pkill -KILL -u postgres
2b: sudo userdel postgres
Deleted postgres server. Re-installed. Got user not found when trying to log into postgres user account through shell.
Tried running postgres server through root and got unable to connect to server through shell.
Re-created postgres user account through root: sudo adduser postgres --disabled-password.
Postgres user through root: sudo usermod -a -G sudo postgres
Still getting unable to connect to server: connection refused. Logged into postgres user. No change.
Re-installed postgres. Same error.
Suggestions?
Thanks a bunch.
You don't exactly need a user who is named postgres, you need a user who owns the data directory, the binaries and configuration files. You should check which uid and gid are now associated with your data directory, then create a user with that specific uid and gid. But check who those id's belong to first. If no user currently has those uid and gid then create a new user with those values:
useradd -u 123 -g 456 postgres
Alternatively, re-create user postgres and assign data directory and binaries to that new user (assuming group postgres still exists):
useradd -G postgres postgres
chown -r postgres:postgres $PGDATA
chown -r postgres:postgres /wherever/bin/is
chown -r postgres:postgres /wherever/conf/is
Found the answer, Read below.
Been on another rabbit hole hunt. Heard about the data file,
how someone deleted it and it has all kinds of info(config
stuff) in there. Also heard how some config files get left
around even after uninstalling the program. Not just config
files but a lot of other files get left around also with
other programs that I have installed and uninstalled.
So here I go to start just deleting a bunch of stuff and then
I go to this link to postgresql.org where it shows about
where the 'data file' is. Or I think maybe it is the 'data file'.
This page says the data file is usually in
'/var/lib/pgsql/data'. I uninstalled postgresql so I didn't
have a pgsql folder but I saw that there was a 'postgresql' folder
there. So I deleted it and now all is well. Now I am
able to reinstall postgresql with no problems, no cluster
problems or nothing. The 'posgresql' folder had 2 hidden files,
I've learned from the past to always check if there are
hidden files. These hidden files names were 'bash_history' and
'psql_history' & you know they were somehow
stopping a fresh complete installation. After deleting them I
was able to reinstall postgresql, with a newly created
'postgres' user waiting for me.
Its 3:43am in the morning & another rabbit hole in the books.
Happy hunting.
Here is the link that I mentioned:
[https://www.postgresql.org/docs/current/storage-file-layout.html][1]