473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Permission Problems:-)?

I'm trying to build a database. But none of the users I try to use works.
I as normal user doesn't work:

:~> createdb mydb
createdb: could not connect to database template1: FATAL: user "adriel" does
not exist

I as postgresql user doesn't work:
:~> createdb mydb
createdb: could not connect to database template1: FATAL: user "mypostgre"
does not exist

I as root user doesn't work:

# createdb mydb
createdb: could not connect to database template1: FATAL: user "root" does
not exist

I can only start postgresql as root. What am I doing wrong here? How do I do
it right?

Thanks,
Jerome
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 22 '05 #1
7 8068
On Tuesday 27 January 2004 09:31, Jerome Lyles wrote:
I'm trying to build a database. But none of the users I try to use works.

I as normal user doesn't work:
:~> createdb mydb

createdb: could not connect to database template1: FATAL: user "adriel"
does not exist

I as postgresql user doesn't work:
:~> createdb mydb

createdb: could not connect to database template1: FATAL: user "mypostgre"
does not exist


OK - it's complaining it can't connect to template1. This is the database that
contains all the default tables/types/functions etc. that will appear in your
new database.

First thing to check is that PG is running. Does it show up in "ps auxw | grep
postgres"?

If it's running you should check if you can connect to the template1 database
normally. As the postgres user try "psql template1" and see if you can
connect to the DB. If not, you need to look at your pg_hba.conf file
(probably in /var/lib/pgsql/data or similar) and also read the chapter on
client authentication in the manuals (tip - start with trust for localhost
and work outwards).

If PG is running and you can connect to the template1 database, try the
command again (as user postgres). If it still doesn't work log into template1
and try a "CREATE DATABASE" command (see manual for details). Then, come back
to the list and let us know what happened.

--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 22 '05 #2
Jerome Lyles <su******@hawaii.rr.com> writes:
I'm trying to build a database. But none of the users I try to use works.
I think you are confused about the distinction between Postgres users
and Unix users. The set of user names known to the database doesn't
necessarily have anything to do with the set of login names available on
the local system. (If you think about cases where the database is used
by remote users, you'll see why this is a good idea.) If you want to
use database user names that match up with local user names, you have to
specifically create those database user names with the createuser
script. Initially the only user name known to the database is the
"superuser", who has the right to create more database users.

Now in order to use createuser you need to connect as the database
superuser, which seems to be a tad messed up in itself:
I as postgresql user doesn't work:
:~> createdb mydb
createdb: could not connect to database template1: FATAL: user "mypostgre"
does not exist
The name given to the initial database superuser is the name of the
account that ran initdb. It kinda looks like you changed your mind
about the name of the account owning the postgres installation --- you
seem now to be trying to connect as "mypostgre" but the database has no
such username. If you remember what you used before, you can try
createuser -U oldnamehere mypostgre
and be sure to give mypostgre all permissions that createuser asks
about. Then mypostgre will be a second superuser and you can use that
account to create more users. If you don't remember what it was before,
you may be reduced to blowing away the old installation and making a new
one (stop postmaster, rm -rf old data dir, initdb, start postmaster).
I can only start postgresql as root.


I don't think so --- the postmaster will actively refuse to start if you
try to run it as root. Better take another look at exactly what's
happening.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 22 '05 #3
On Tuesday 27 January 2004 12:05 am, Richard Huxton wrote:

OK - it's complaining it can't connect to template1. This is the database
that contains all the default tables/types/functions etc. that will appear
in your new database.

First thing to check is that PG is running. Does it show up in "ps auxw |
grep postgres"?

If it's running you should check if you can connect to the template1
database normally. As the postgres user try "psql template1" and see if you
can connect to the DB. If not, you need to look at your pg_hba.conf file
(probably in /var/lib/pgsql/data or similar) and also read the chapter on
client authentication in the manuals (tip - start with trust for localhost
and work outwards).

If PG is running and you can connect to the template1 database, try the
command again (as user postgres). If it still doesn't work log into
template1 and try a "CREATE DATABASE" command (see manual for details).
Then, come back to the list and let us know what happened.


I have now created a database as user postgre. Thank you!

However I'm still having problems using it as a normal user. I added myself
to the postgres user group but it didn't work.
This is my default configuration:

# CAUTION: The default configuration allows any local user to connect
# using any PostgreSQL user name, including the superuser, over either
# Unix-domain sockets or TCP/IP.

# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD

#local all all trust
# IPv4-style local connections:
#host all all 127.0.0.1 255.255.255.255 trust
# IPv6-style local connections:
#host all all ::1
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff trust
local all all ident
sameuser
"/var/lib/pgsql/data/pg_hba.conf" 63L, 3374C 63,1
Bot

When I check to see if PG is running as a normal user I get this:

:~> ps auxw | grep postgres
postgres 11956 0.0 0.2 17960 2296 pts/3 S Jan26
0:00 /usr/bin/postmaster -D /var/lib/pgsql/data
postgres 11959 0.0 0.2 8760 2072 pts/3 S Jan26 0:00 postgres: stats
buffer process
postgres 11960 0.0 0.2 7768 2120 pts/3 S Jan26 0:00 postgres: stats
collector process
adriel 14819 0.0 0.0 1828 604 pts/2 R 11:26 0:00 grep postgres

And when I try to create the db as a normal user I get this:

:~> createdb mydb1
createdb: could not connect to database template1: FATAL: user "adriel" does
not exist

So...whats next?
Jerome
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #4
On Tuesday 27 January 2004 06:41 am, Tom Lane wrote:
Jerome Lyles <su******@hawaii.rr.com> writes:
I'm trying to build a database. But none of the users I try to use
works.
I think you are confused about the distinction between Postgres users
and Unix users. The set of user names known to the database doesn't
necessarily have anything to do with the set of login names available on
the local system. (If you think about cases where the database is used
by remote users, you'll see why this is a good idea.) If you want to
use database user names that match up with local user names, you have to
specifically create those database user names with the createuser
script. Initially the only user name known to the database is the
"superuser", who has the right to create more database users.


You're correct, I was confused about this point. As soon as I finish here I
will use the createuser script. I wish I had read your email before I sent
my last one, I think your explanation and createuser are the answer to my
question in that email.
Now in order to use createuser you need to connect as the database

superuser, which seems to be a tad messed up in itself:
I as postgresql user doesn't work:
:~> createdb mydb

createdb: could not connect to database template1: FATAL: user
"mypostgre" does not exist
The name given to the initial database superuser is the name of the
account that ran initdb. It kinda looks like you changed your mind
about the name of the account owning the postgres installation --- you
seem now to be trying to connect as "mypostgre" but the database has no
such username.


Correct again. I tried to set up and use the initial database superuser
(mypostgre). I didn't realise that apt had set up the database superuser
(postgres) when it installed postgresql. When I did realize it I was able to
use it to set up a database.
I can only start postgresql as root.


I don't think so --- the postmaster will actively refuse to start if you
try to run it as root. Better take another look at exactly what's
happening.


Well two out of three isn't bad:-). I'll let you be the judge:
Running the postmaster as root:

adriel@linux:~> su
Password:
linux:/home/adriel # /etc/init.d/postgresql start
Starting PostgreSQL
done
linux:/home/adriel #

I then created a database as the database superuser:

postgres@linux:~> createdb mydb2
CREATE DATABASE

Here is some additional information:

postgres@linux:~> ps auxw | grep postgres
postgres 15646 0.0 0.1 2664 1136 pts/1 S 12:13 0:00 su - postgres
postgres 15647 0.0 0.1 3216 2040 pts/1 S 12:13 0:00 -bash
postgres 18973 0.0 0.2 17960 2296 pts/3 S 14:47
0:00 /usr/bin/postmaster -D /var/lib/pgsql/data
postgres 18975 0.0 0.2 8760 2072 pts/3 S 14:47 0:00 postgres: stats
buffer process
postgres 18976 0.0 0.2 7768 2120 pts/3 S 14:47 0:00 postgres: stats
collector process
postgres 18986 0.0 0.0 2668 708 pts/1 R 14:49 0:00 ps auxw
postgres 18987 0.0 0.0 1828 608 pts/1 R 14:49 0:00 grep postgres
postgres@linux:~>

The only difference that I noticed between the root postmaster and the
postgres postmaster is that the postgres postmaster demanded a password
before opening.
Now to create some users:-).
Thanks,
Jerome


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 22 '05 #5
On Tue, Jan 27, 2004 at 03:08:23PM -1000, Jerome Lyles wrote:
I don't think so --- the postmaster will actively refuse to start if you
try to run it as root. Better take another look at exactly what's
happening.
Well two out of three isn't bad:-). I'll let you be the judge:
Running the postmaster as root:

adriel@linux:~> su
Password:
linux:/home/adriel # /etc/init.d/postgresql start
Starting PostgreSQL
done


If you look closely at the script, you'll see that the postmaster is not
run as root, but rather under "su - postgres". (You should be aware
that the start script is very different and separate from the postmaster
program.) So Tom gets 3/3, and you will know sooner or later that he
scores 100% most of the time.
postgres@linux:~> ps auxw | grep postgres
postgres 18973 0.0 0.2 17960 2296 pts/3 S 14:47 0:00 /usr/bin/postmaster -D /var/lib/pgsql/data


See, this is not running as root.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"¿Cómo puedes confiar en algo que pagas y que no ves,
y no confiar en algo que te dan y te lo muestran?" (Germán Poo)

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 22 '05 #6
Jerome Lyles <su******@hawaii.rr.com> writes:
On Tuesday 27 January 2004 06:41 am, Tom Lane wrote:
I don't think so --- the postmaster will actively refuse to start if you
try to run it as root. Better take another look at exactly what's
happening.
Running the postmaster as root: adriel@linux:~> su
Password:
linux:/home/adriel # /etc/init.d/postgresql start
Starting PostgreSQL If you look into that startup script, you'll find it does a su to
postgres before trying to start the postmaster. The postmaster will
barf if you try to invoke it directly as root (this is a security
measure).
I then created a database as the database superuser: postgres@linux:~> createdb mydb2
CREATE DATABASE


Okay, looks like you are set: postgres is the DB superuser, and
should be able to create all the other database users you want.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 22 '05 #7
On Tuesday 27 January 2004 03:51 pm, Alvaro Herrera wrote:
On Tue, Jan 27, 2004 at 03:08:23PM -1000, Jerome Lyles wrote:
I don't think so --- the postmaster will actively refuse to start if
you try to run it as root. Better take another look at exactly what's
happening.


Well two out of three isn't bad:-). I'll let you be the judge:
Running the postmaster as root:

adriel@linux:~> su
Password:
linux:/home/adriel # /etc/init.d/postgresql start
Starting PostgreSQL
done


If you look closely at the script, you'll see that the postmaster is not
run as root, but rather under "su - postgres". (You should be aware
that the start script is very different and separate from the postmaster
program.) So Tom gets 3/3, and you will know sooner or later that he
scores 100% most of the time.
postgres@linux:~> ps auxw | grep postgres
postgres 18973 0.0 0.2 17960 2296 pts/3 S 14:47 0:00
/usr/bin/postmaster -D /var/lib/pgsql/data


See, this is not running as root.


I stand corrected and it feels good:-).
Thanks for your excellent help Tom and Richard.
Sincerely,
Jerome
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Nick Zdunic | last post by:
I have this code which throws up an error on my box (Windows Sever 2003 - Enterprise Edition) MsgBox("Message", MsgBoxStyle.Question OrMsgBoxStyle.MsgBoxSetForeground, "Title") I have tried...
1
by: www.douglassdavis.com | last post by:
I screwed up the permissions on my database. Basically I revoked all the permissions of the root account on the mysql table. To try to fix this, I went through all of the instructions here: ...
4
by: Marcin Zmyslowski | last post by:
Hello! I have a few tables in MS SQL Server 2000, where I have admin permissions for these tables. I have created a blank database in MS Access 2003, where I linked a table from MS SQL Server...
15
by: sflynn | last post by:
I've just created a new program in Visual Studio 2005, Visual Basic. I can publish, install, and run the program just fine as long as the user is a member of the "Domain Admins" group. My problem...
6
by: Benjamin | last post by:
Hello, I'm running PHP 5.2.0 as a Apache 2.2 server module. When, I try to unlink I get this: "Warning: unlink(file.txt) : Permission denied..." What and how do I change this so it works? Thanks
0
by: neoret | last post by:
Hello. I have developed an application (an office addin).The application works fine with no error messages on my devoping machine (that machine is not connected to any domains). I have...
10
Mague
by: Mague | last post by:
Hey, I am using a server of my friends, and i created a directory through php with exec("mkdir $dir") these are now imposible to get into and delete. (well not impsobile, impossible for a kid my...
5
by: sayeo87 | last post by:
Hi, I am quite new to JSP so please forgive me if I ask really simple things... I am trying to run system commands on the server and display the output on a webpage. This is what I've got: <%@...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.