Re: [NOVICE] Why psql connection assumes default database name asthe username
От | hubert depesz lubaczewski |
---|---|
Тема | Re: [NOVICE] Why psql connection assumes default database name asthe username |
Дата | |
Msg-id | 20170323131232.GC16353@depesz.com обсуждение исходный текст |
Ответ на | [NOVICE] Why psql connection assumes default database name as the username (Neha Khatri <nehakhatri5@gmail.com>) |
Ответы |
Re: [NOVICE] Why psql connection assumes default database name as the username
|
Список | pgsql-novice |
On Thu, Mar 23, 2017 at 03:57:58PM +1100, Neha Khatri wrote: > For psql connection, the default database name is assumed to be operating > system user name. Is it a common practice to have a database name same as > an OS username. Or would the applications create a database with the OS > username as some default procedure? it's not that database name is assume to be operating system user name. psql (or specifically libpq) makes two assumptions: 1. if username is not given - use operating system user name 2. if database name is not given - use username as db name. So, if you don't have anything set in environment, and you're logged in a neha, then: $ psql will try to connect to db neha with user neha $ psql -U depesz will try to connect to db depesz with user depesz $ psql -d xxx will try to connect to db xxx with user nega $ psql -U depesz -d xxx will try to connect to db xxx with user depesz > In my specific case the problem is just that the database 'pgadmin' is not > there, then why should it be a FATAL error. I understand that any process > aborting errors are treated FATAL. But it looks like a simple error here. Levels or errors are clearly defined: 1. ERROR means that something was wrong, but you can still continue to work in the db connection 2. FATAL means that something wrong happened, and you can't use the connection any more as it has closed. Since failing to open db connection prohibits you from doing any more work in the db connection (which is not there) - it's clearly FATAL and not ERROR. depesz
В списке pgsql-novice по дате отправления: