Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2012
    Posts
    30

    Unanswered: Pgadmin Does CREATE DATABASE but psql does not

    Hi to All,

    Could Someone resolve this problem?

    If a Database "MYDB" is created with Pgadmin there is no problem.

    But if it is invoked psql as superuser (postgres) no command is executed. Neiher the other command as "initdb"

    Instead if, in psql is typed the command "\l", all DB are seen.

    I tried with psql installed in my laptop, in the linux server; with psql of Postgres 8.4.1; 9.0; 9.2, but it was obtained the same effect.

    It may be a banal quaestion for You.

    Tanks in advance.
    Gianni Pinna

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    But if it is invoked psql as superuser (postgres) no command is executed.
    "No command is executed" is not a valid PostgreSQL error message.
    You did terminate the CREATE DATABASE with a semicolon, right?

    Please copy and paste the output of the command line window, e.g. like this:

    Code:
    psql (9.2.1)
    Type "help" for help.
    
    postgres=# create database foobar;
    CREATE DATABASE
    postgres=#
    (Posting text is much preferred over posting a screenshot!)

    Neiher the other command as "initdb"
    Initdb is a operating system "command" (i.e. program). You should not run that from within psql (and as PostgreSQL is already running you don't actually need it). But again: you have to include any error message you get when posting such a question.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Dec 2012
    Posts
    30

    Resolved

    Hi Shamat,

    tank You very much, with Your suggest it was resolved, and now it is possible to produce database from sql.

    But, Shamat, this was a means ordered to the end of the first problem.



    (1) After that I made the backup in the server (postgres 8.4) trough the following crontab command

    Code:
    #!/bin/bash
    /opt/PostgreSQL/8.4/bin/pg_dump -h localhost -U postgres -c -R -v AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE > /root/backups/AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE.sql


    (2) I have installed in the laptop postgres 9 with the intention of
    importing the dump in the laptop.



    (3) I have tried with the following command:
    Code:
    postgres# psql -h localhost -U postgres -W -e AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE -f  "C:\Utenti\Gianni\Desktop\AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE.sq"


    (4) But, therefore I did not put ";" at the end of the command I did not have any result. So I tried with other commands as initdb, with the same effect.



    (5) At this point Your replay, Shamat, and Your ";" solution.



    (6) So I tried to type again the command (3) with " ;"

    Code:
    postgres# psql -h localhost -U postgres -W -e AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE -f  "C:\Utenti\Gianni\Desktop\AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE.sq"


    (7) But I had this output:

    Code:
    ERROR: syntax error at or near "psql"
    RIGA1 :  psql -h localhost -U postgres -W -e AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE...
             ^
    Postgres#


    (8) I had this result also after the creation in the laptop of the DB AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE


    This is the proble in all its extension.


    Hope You can resolve.
    Tanks again for the last solution of Your .
    Tanks in advance, Shamat, for having you read this replay.

    Best Rgrds
    Gianni Pinna.

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    syntax error at or near "psql"
    This seems as if you SQL file contains the call to psql again.

    What's the content of the file "AVEMARIABAMBINAMADREDIDIOMOGLIEDISANGIUSEPPE. sq" ?

    And why don't you simply use psql in interactive mode?

    Btw:
    "replay" means "something is played again".
    A "reply" is an answer to a question.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •