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.
Related
Windows 10 user trying to either delete a role permanently so the error doesn't show up or create a superuser with no password.
Been searching for hours to no avail. Tried:
Creating a new user and database with
CREATE USER Nistic SUPERUSER;
CREATE DATABASE registration WITH OWNER Nistic;
The role was successfully created, but upon logging out, and back in, typing "psql" into the terminal will still bring up the same error. [EDIT] I can login with the postgres username by typing psql -U postgres, but for whatever reason the default username is still set to Nistic.
I've already checked the conf file and set all the methods to trust. I tried dropping the user and recreating the user.
I just wanted the title to include User to be more general, despite showing Nistic above.
I've pretty much tried everything else that I could find on SO.
Please help, thank you.
Screen below to show some of the oddness (please read each line before commenting - the issue is that after getting rid of Nistic, it still expects Nistic)
I have just installed Postgres 12 on a Mac. As you may soon appreciate I am totally new to it.
During the installation process I was asked to provide a "password". I do not remember specifically, but I think it was for the some sort of admin role.
Now I want to create my first database. Reading the documentation I insert the command
createdb myfistdb
the system asks for a password. I give the one I set during the installation processes but I got the following error
createdb: error: could not connect to database template1: FATAL: password authentication failed for user "myusername"
where myusername is the user I am logged in.
The same happens if I give the system password of myusername.
I understand that my question is pretty basic, but I have been struggling quite some time without any success, so any help will be appreciated.
The database uset name used by createdb defaults to the operating system user name, so you'll have to specify the administrative superuser explicitly:
createdb -U postgres myfistdb
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.
I installed openerp 7 on ubuntu and worked for a while.
When I restarted ubuntu, I opened openerp and tried to login but didn't find the databases I've created before and it took me to the (Database Management) page in order to create a new database as if it were my first time.
I tried to make a duplicate of an existing database as a workaround, but when I wrote the old database name, I got this message:
ProgrammingError: permission denied to copy database "test"
I tried to access postgres using pgadmin and I succeeded and could access all the databases from the pgadmin.
You need to give the access rights on particular database for particular openerp user.
First Create the OpenERP user that will own and run the application
sudo adduser --system --home=/opt/openerp --group openerp
Then Next,
First change to the postgres user so we have the necessary privileges to configure the database.
sudo su - postgres
Now create a new database user. This is so OpenERP has access rights to connect to PostgreSQL and to create and drop databases. Remember what your choice of password is here; you will need it later on:
createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp
Enter password for new role: ********
Enter it again: ********
Finally exit from the postgres user account:
exit
Here is source link http://www.theopensourcerer.com/2012/12/how-to-install-openerp-7-0-on-ubuntu-12-04-lts/
I am uncertain if its the permissions issue or something I am doing wrong and any help will be greatly appreciated.
I have a dedicated Ubuntu server with Postgres DB installed on it. I want to backup the databases, but when I use pg_dump I get permission denied. Can some one help me out?
Here are a few details about my set up.
On postgres: I have the following databases.
postgres,
template0,
template1,
mydb,
mydb1
I have 2 PostgreSQL users
postgres,
mydb (There are no postgresql groups defined yet)
All the other settings for postgres are default values.
On my ubuntu itself, I have 2 users.
user1,
mydb
I logged into the box as root/user1 using SSH, issued the following commands,
$ pg_dumpall > a.sql
I get, -bash: a.sql: Permission denied
Same goes with pg_dump command.
I know I am missing something here. Can some one guide me to properly issue this command?
TIA.
I get, -bash: a.sql: Permission denied
Same goes with pg_dump command.
This looks more like a file permission issue. Does the OS user have the right to write the dump file? Check file/directory permissions.
When you run the command
pg_dumpall > a.sql
then your shell will attempt to create the file a.sql in the current directory. If you (as "user1") do not have permission to create files in the current directory, then first use the cd command to change to a directory where you do have permission. You can use the pwd command to see what the current directory actually is.