Creating o non-existing database

Discussion in 'Perl Misc' started by Nikos, Apr 12, 2005.

  1. Nikos

    Nikos Guest

    This is soem per of my make.pl
    Its supposed to create first time the database nikos_db or if its
    already there to just delete it and recreate it.

    $db = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net')
    ? DBI->connect('DBI:mysql:nikos_db', 'root', '')
    : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', '*****')
    or print font({-size=>5, -color=>'Lime'}, $DBI::errstr) and exit 0;

    $db->do( "drop database if exists nikos_db" );
    $db->do( "create database nikos_db" );
    $db->do( "use nikos_db" );

    If the database alrady exists no problem but if it want to be creates at
    the time then the first db gives an error when i run make.pl and i must
    then manually create it through mysql statemets in console.

    What can i do so that Perl create the database nikos_db if it never benn
    created?
     
    Nikos, Apr 12, 2005
    #1
    1. Advertising

  2. Nikos <> wrote:

    > This is soem per of my make.pl



    Huh?

    Is that supposed to be an English sentence?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Apr 13, 2005
    #2
    1. Advertising

  3. Nikos

    peter pilsl Guest

    Nikos wrote:
    >
    > If the database alrady exists no problem but if it want to be creates at
    > the time then the first db gives an error when i run make.pl and i must
    > then manually create it through mysql statemets in console.
    >


    Evidentely this is not a perl-problem. I dont know what it takes on your
    sql-server to create a database. With postgreSQL there are mainly two
    options:
    i) call an extra programm coming with pgSQL
    ii) connect to another database and create the needed database. Best the
    postgres-system-datebase is used, cause it exists on most installations.

    peter




    --
    http://www.goldfisch.at/know_list
     
    peter pilsl, Apr 13, 2005
    #3
  4. Nikos wrote:
    > What can i do so that Perl create the database nikos_db if it never benn
    > created?


    You could check how it's done in Webmin.

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
     
    Gunnar Hjalmarsson, Apr 13, 2005
    #4
  5. Nikos

    Spock Guest

    Whats Webmin?
     
    Spock, Apr 15, 2005
    #5
  6. Gunnar Hjalmarsson, Apr 15, 2005
    #6
  7. Nikos

    Guest

    Nikos <> wrote:
    > This is soem per of my make.pl
    > Its supposed to create first time the database nikos_db or if its
    > already there to just delete it and recreate it.
    >
    > $db = ($ENV{'SERVER_NAME'} ne 'nikolas.50free.net')
    > ? DBI->connect('DBI:mysql:nikos_db', 'root', '')


    ? DBI->connect('DBI:mysql', 'root', '')

    > : DBI->connect('DBI:mysql:nikos_db:50free.net', 'nikos_db', '*****')


    : DBI->connect('DBI:mysql::50free.net', 'nikos_db', '*****')

    > or print font({-size=>5, -color=>'Lime'}, $DBI::errstr) and exit 0;
    >
    > $db->do( "drop database if exists nikos_db" );
    > $db->do( "create database nikos_db" );
    > $db->do( "use nikos_db" );
    >
    > If the database alrady exists no problem but if it want to be creates at
    > the time then the first db gives an error when i run make.pl and i must
    > then manually create it through mysql statemets in console.


    If you read the error it gives, then it should have been obvious what the
    problem was. You can't connect to the server and specify a non-existant
    database as your default. Connect the server without specifying any default
    database, (re)create the database you want, then switch into it.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Apr 15, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christina N
    Replies:
    0
    Views:
    355
    Christina N
    Jun 21, 2004
  2. Phil Winstanley [Microsoft MVP ASP.NET]

    Re: IIS errormessage referrs non-existing linenumber

    Phil Winstanley [Microsoft MVP ASP.NET], Jun 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    332
    Christina N
    Jun 21, 2004
  3. nrm
    Replies:
    3
    Views:
    542
  4. Replies:
    0
    Views:
    193
  5. beatnik
    Replies:
    7
    Views:
    105
Loading...

Share This Page