reading a txt file: Permission denied - postgis - postgresql

I get this error while trying to copy some data from a txt file to a table in a database, in postgis/postgres... (I am using windows 10).
ERROR: could not open file "C:\Users\Luchito\Desktop\output_1.txt" for reading: Permission denied
The file has all permission "on"... Any help?

Postgresql does not run with administrator privileges dans does not have access to your own user space most likely.
If you do a right click on the file, click Properties then Security, then Users (or Authenticated Users I am not sure) and check Full Control. It should allow Postgres to read the file

Related

Importing csv in postgres from pgAdmin 4 | google-cloud-sql

I created a database and a user from the dashboard. I used cloud-sql-proxy to connect to the database and was able to succesfully connect from pgAdmin4. Now I tried to use the functionalities of pgAdmin4 to upload a csv to a table which had already been created by an appengine app which I have. When I try to upload this csv I get the error: ERROR: permission denied for table data
The command pgAdmin4 is trying to run is: --command " "\\copy public.data (\"Date\", \"Open\", \"Close\", \"High\", \"Low\") FROM 'C:/Users/username/folder/datafile.CSV' DELIMITER ',' CSV HEADER ;""
I tried to log in from the cloud console and grant all permissions to this user but this also failed.
I found this article on how to upload a csv from a Cloud Storage https://cloud.google.com/sql/docs/postgres/import-export/import-export-csv but this is not exacly what I want to achieve here...

Firebird permission denied when connecing with FlameRobin but is okay with isql

I'm trying to connect to employee.fdb in Firebird3.0 (localhost) using FlameRobin 0.9.3 on a Ubuntu OS.
The connection to Firebird using isql has no issues. I can create users, roles, etc all from the terminal. However, when I attempt to make a connection using FlameRobin I receive a 335544344 "Error while trying to open file Permission denied" response.
This occurs with the SYSDBA profile and any other new user profiles that I create in isql. I can even create new users in FlameRobin but I cannot connect to any database. I've verified in /etc/firebird/3.0/firebird.conf that DatabaseAccess = Full and have attempted to access the db from a couple different folders in case this is a read/write issue. No success.
I feel like I'm missing something obvious. Any thoughts?
Added info in response to Mark (4/26):
The db is stored in /var/lib/firebird/3.0/data/. I have assumed this to be the default location for Firebird DBs and that the server automatically has access to it, but I suppose that might not be the case. Is there a way to confirm server permissions to this directory and/or is this the customary spot to store work?
Terminal Connection with ISQL:
daniel#daniel-desktop:~$ isql-fb
Use CONNECT or CREATE DATABASE to specify a database
SQL> connect '/var/lib/firebird/3.0/data/employee.fdb' user sysdba password 'xxxxxxx';
Database: '/var/lib/firebird/3.0/data/employee.fdb', User: SYSDBA
SQL>
FlameRobin Database Registration Info:
FlameRobin Error:
This is a permissions issue as #MarkRotteveel suggested. Problem was that I installed the server as a user and not as root. Problem solved by removing and reinstalling both Firebird and FlameRobin as root.

AWS Ec2 postgres \copy...: permission denied

I have an aws ec2 instance that is running postgres on it. I have a file in the same instance that is a csv file so that I can populate the database. When I go into postgres to run the copy file, it is saying that the permission is denied. I am accessing the postgress shell with a superuser. I am not sure why I am getting a permission denied. Here is a screen shot of what I am running and error I am getting.
You don't say what OS user has launched psql, but presumably it's postgres.
It doesn't have the right to read any file inside /home/ec2-user because this directory has permissions drwx------, meaning that only ec2-user or root can look into it (the fact that the CSV file itself has world-wide read permissions is not sufficient, all directories in the hierarchy must have the x bit set to allow traversal).
The most common solutions:
1) chmod 755 /home/ec2-user so postgres can access it.
2) Launch psql under the ec2-user with an explicit -U option to specify a database user. This may also mean that a password is going to be asked, depending on Postgres authentication rules set in pg_hba.conf. You may also edit these rules if you're an admin and they don't match your needs.
3) Put the CSV data files in a dedicated directory that both ec2-user and postgres can read, so typically that would be outside of any /home directory.

Import text file to postgresql permission denied

I'm trying to import data from a text file into a table. The table is empty but the schema is there. I run the command
\copy tbl_windspeed from '/home/~~~myname~~~~/Documents/csv_windspeed.txt'
It tells me Permission denied. I check the file's permissions and even set it to chmod 777 so it's now -rwxrwxrwx. I'm not sure what I'm doing wrong. I even tried restarting the server? service postgresql restart
I'm not exactly sure why this worked but I found a solution:
I was logged in as "postgres" and I guess it didn't like that. I created a new user with login, and created that database and tables through that user (so it has owner privileges). Since that new user I created had the same username as my linux user name, I think that's why I was able to import that file.
Can I not use the user "postgres" to import files on my laptop? When I login to psql I login through sudo -u postgres -i, I have to put in a password. So, it knows I am authenticated as the root user. If someone could give me some more info or explain why that is the case that would be appreciated.

Using Postgres PGCrypto encryption requires superuser to run view queries

Using: Postgres 9, CentOS 7,
Postgres Data directory not in default location but used RSync to make sure permissions were correct. And yes appropriate .config files were changed.
When I try to query a view containing an encrypted item as a NON superuser (Testuser), I get this error:
ERROR: must be superuser to read files CONTEXT: PL/pgSQL function
decrypt_data(bytea) line 13 at assignment
If I run that same query using POSTGRES superuser, the query completes fine.
This seems to be a file system read permission error when trying to read the Key files. Everything I see using encryption seem to not mention how to run without being superuser.
I have already run the following grants for Testuser:
GRANT ALL PRIVILEGES ON DATABASE xxx_db to Testuser;
GRANT SELECT ON ALL TABLES IN SCHEMA xxxxx TO Testuser;
GRANT ALL ON ALL TABLES IN SCHEMA xxxxx TO Testuser;
The test user can create tables, views, basically anything within that db.. just not read encryption keys.
The permissions on the keys are 775 right now, I even tried 777 without luck.
Any Ideas?
pgcrypto is a PostgreSQL extension described here:
https://www.postgresql.org/docs/current/static/pgcrypto.html
but it doesn't provide a decrypt_data(bytea) function.
This function seems to be custom code that happens to open a server-side file, with pg_read_file() or a similar method.
These methods are restricted to superusers to avoid normal users to read on the server's filesystem, no matter what are the Unix rights of the particular file they want to read.
You can verify this in the source of decrypt_data(bytea), which can be obtained with:
select pg_get_functiondef('decrypt_data(bytea)'::regprocedure);
or \df+ decrypt_data(bytea) from within psql.
I found the issue. I need to grant the user with function permissions.
GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA xxxxx TO yyyyyyyyy;