I try to set up a PostgreSQL-server (to learn Spring).
As I am new to PostgreSQL, I have difficulties to frame my problem.
Problem description:
I started postgresql:
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mo 2017-08-21 19:10:46 CEST; 20min ago
Process: 28211 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 28211 (code=exited, status=0/SUCCESS)
PostgreSQL is running on my local machine (Ubuntu 16.04). So no remote server ect.
Trying to populate Postgres with data:
sudo psql -h 127.0.0.1 -U postgres -f create_soba_psql.sql
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
Tried pw: postgre, postgres, with pw from current user of OS
BUT
sudo -u postgres psql
creates a connection
(with pw from current user of OS).
So something new to me to be learned...
What I already tried:
Resetting pw for postgres with: $ sudo passwd postgres
Looking into the PostgreSQL Client Authentication Configuration File
screenshot configuration
I think "peer" should be ok, as I do not connect to a remote server, isn't it?
Reinstalling PostgreSQL and trying everything again. At least the error did not change...
Do you, dear reader, have a hint what I can try or even have a solution/ explanation what I am doing wrong?
Kind regards,
Niklas
do:
sudo -u postgres psql
in psql session, run:
alter user postgres password 'some_pw';
quit the session and try:
sudo psql -h 127.0.0.1 -U postgres -f create_soba_psql.sql
when asked use password some_pw
Related
I've upgraded MariaDB from 5.5 to 10.2 (on CentOS 7.7) following this tutorial: https://support.plesk.com/hc/en-us/articles/213403429
MariaDB 10.2 is running. User/Websites can connect to their databases. But I can't connect with admin anymore.
MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin --all-databases --routines --triggers > /tmp/all-databases-new.sql
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 1045 (28000): Access denied for user 'admin'#'localhost' (using password: YES)
FATAL ERROR: Upgrade failed
I tried to set a new password for admin but...
systemctl stop mariadb
[root#host ~]# mysqld_safe --skip-grant-tables --skip-networking &
[1] 76597
[root#host ~]# 200317 08:23:11 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
200317 08:23:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[1]+ Done mysqld_safe --skip-grant-tables --skip-networking
[root#host ~]# mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
It's no longer possible to access the Plesk GUI because Plesk can't access the psa database anymore. What to do now?
Many thanks in advance!
The reason why "mysqld_safe --skip-grant-tables --skip-networking &" failed was, that Mariadb could not write the pid-file. Mariadb tried to write it it in /var/run/mariadb but that directory was non existent. You can create the directory or change the configuration, so that Mariadb uses another directory for the pi-file. After that it was possible to execute "mysqld_safe --skip-grant-tables --skip-networking &" and to set a new password for the database user "admin".
For all internal purposes, Plesk gets the database password from /etc/psa/.psa.shadow. So I put it in plain text, which works but of course plain text is bad. Does anybody know how to store the password as hash again? I think it was stored as AES128 hash, which needs the right secret?
This is my first time trying to setup mssql server under linux server.
This is my error
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed.
The login is from an untrusted domain and cannot be used with
Integrated authentication..
I could login using "sa" and password
Once I use sqlcmd -E -S linuxsqlserver or sqlcmd -S linuxsqlserver I received the error above.
I followed 2 guide in the link
https://www.mssqltips.com/sqlservertip/5075/configure-sql-server-on-linux-to-use-windows-authentication/
https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-active-directory-authentication?view=sql-server-2017
My current system
Ubuntu 18.04
MSSQL
Window Server 2016
AD
What I have done:
join domain (the domain name is Test1)
Creating the Service Principal Name
setspn -a MSSQLSvc/linuxsqlserver.TEST1.COM:1433 sqllinux
Creating the Keytab File for the SQL Server Service
kinit sqllinux#TEST1.COM
kvno MSSQLSvc/linuxsqlserver.TEST1.COM:1433#TEST1.COM (returned 2)
sudo ktutil
addent -password -p MSSQLSvc/linuxsqlserver.Test1.COM:1433#Test1.COM -k 2 -e aes256-cts-hmac-sha1-96
addent -password -p MSSQLSvc/linuxsqlserver.Test1.COM:1433#Test1.COM -k 2 -e rc4-hmac
wkt /var/opt/mssql/secrets/mssql.keytab
quit
Setting up Active Directory Authentication for SQL Server
/opt/mssql/bin/mssql-conf set network.kerberoskeytabfile /var/opt/mssql/secrets/mssql.keytab
systemctl restart mssql-server
Thank you in advance.
I want to set up the psql terminal tool in Centos 6.6
I have been given access to as database and i just want to use the terminal for writing queries to the database for information. I have no prior experience with psql before but I want to move on from the pgadmin3 gui.
I started off by installing psql:
yum install postgresql
but when I try to access it, ie. typing [root#localhost]# psql I get the following error:
psql: FATAL: database "root" does not exist
I've tried using:
psql --host=<DB instance endpoint> --port=<port> --username=<master user name> --password --dbname=<database name>
but that fails to work too, maybe this is really basic but im completely lost for setting this up
Use:
psql -U my_pgadmin_username postgres
or
psql -U my_pgadmin_username -h localhost postgres
Alternately, more typical usage:
sudo -u postgres psql
I am trying to copy one table from one database to another:
sudo -u postgres pg_dump -t _stats db30 | psql db8;
However, I always get asked for a password, and I do not know what it is. Is there a way to do this without pg_dump? Is there a way so that I can not be asked for a password when I run psql?
Note, to get into postgres I have to run sudo -u postgres psql instead of psql
User management and permission on a postgres server is a complex topic, but you have probably only a server installed on your desktop and use it only on localhost, so security is not so important.
You have to do 3 steps:
1) Edit the pg_hba.conf file and restart the server
2) Login with psql and set a password for the user postgres
3) Edit (or create) the file ~/.pgpass
NOTE: you could use the authentication method trust in pg_hba.conf and avoid the step 2 and 3, but this is really TOO permissive, and you shouldn't use it, even on localhost.
The pg_hba.conf file
To understand the file pg_hba.conf please read here: http://www.postgresql.org/docs/9.4/static/auth-pg-hba-conf.html
Basically, if you server is on localhost and security does not matter, you can simply allow all user to connect with md5 authentication method.
If you don't know, where this file is, use this command:
locate pg_hba.conf
Probably is in /etc/postgresql/9.3/main/pg_hba.conf or similar.
Edit the file and change the already existing lines so (at end of the file):
local all all md5
host all all 127.0.0.1/32 md5
Now restart the server with
sudo service postgresql restart
Set a password for the user postgres
First login in psql:
sudo -u postgres psql
Now, within psql, change the password:
ALTER USER postgres PASSWORD 'your-password';
The pgpass file
Now you can login in psql with psql -U postgres (without sudo -u postgres) but have to enter the password. To avoid to digit the password every time, you can set up the pgpass file. If does not already exist, you must create a file named .pgpass in your home directory. The file must be owned by your user and be readable only by your user:
chown $USER:$USER ~/.pgpass
chmod 600 ~/.pgpass
Now write in the file those lines:
localhost:5432:*:postgres:your-password
127.0.0.1:5432:*:postgres:your-password
Alternately you can use the environment variable PGPASSWORD: http://www.postgresql.org/docs/9.4/static/libpq-envars.html
Ready. Now you can login in postgres with psql -U postgres without enter the password.
I have started the pgpool using the command
sudo pgpool -n &
it started giving the following message on the terminal:
2012-05-04 10:54:29 LOG: pid 4109: pgpool-II successfully started. version 2.3.2.1 (tomiteboshi)
But when I try to run the following command:
createdb -p 9999 bench_replication
I get the following error message:
createdb: could not connect to database postgres: 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.9999"?
When I change the port from 9999 to 5432, a database bench_replication is created on the local node only, not on slave nodes. But, tutorial say to mention port 9999 in this command in order to create database bench_replication on all slave nodes through pgpool.
To confirm whether pgpool is really running or not, I stop the pgpool using command
2012-05-04 10:58:50 LOG: pid 4109: received smart shutdown request
stop request sent to pgpool. waiting for termination...done.
[1]+ Done sudo -A pgpool -n
which confirms the pgpool was actually running. What am I doing wrong? I have changed all my pgpool configuration file as mentioned in the standard tutorials on net.
Try this command :
createdb -p 9999 -h 127.0.0.1 bench_replication
By default PostgreSQL try to use the socket.
Late response but useful for future generations:
When you run
createdb -p 9999 bench_replication
under root, this generates the following error in log:
no pg_hba.conf entry for host "12.34.56.78", user "root", database
"postgres", SSL off
This means you should explicit mention username just like this:
createdb -U postgres -p 9999 bench_replication
Then you will get another error:
no pg_hba.conf entry for host "12.34.56.78", user "postgres", database
"postgres", SSL off
So you were blocked by second node on HBA level.
In this case either you should allow on second node access from first (in pg_hba.conf):
host all postgres 12.34.56.77 trust
or you should set password:
createdb -U postgres -p 9999 bench_replication -W SoMeP4Ssw0rD
If this is not clear enough - just check for your logs.