Here is what I would do.


There is always a database on every mysql installation called "mysql"

This database is where your permissions tables and such are stored.

Connect initially to that database.  Then, try to create the new database.
If you get an error back, prompt the user, rinse and repeat.

Your connection string should look something like this:
$dbh =
DBI->connect('DBI:mysql:mysql;host=somehost','someuser','somepassword');

Of coarse, you could always connect to the mysql database and get a list of
databases, and not have to expect an error back from mysql on connection...

----- Original Message -----
From: "John Tsangaris" <[EMAIL PROTECTED]>
To: "Eric Fitzgerald" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, February 16, 2001 4:46 PM
Subject: RE: Perl DBI


> Hi, Eric.
>
> What I'm trying to do is have my install program check to see if a
database
> of a certain name exists, if it does then the install needs to create
> another one (using a name given by the user), if not then it needs to
create
> it with the original name.
>
> But I cannot figure out how to connect to mysql without already having a
> database setup.
>
> I'll use dbtemp as an example db.
>
> I can try to connect to dbtemp and if it successful, I know it exists.  So
I
> prompt the user to enter another db name.  I can then check if this exists
> and if it doesn't I can use the dbi to create the new db WHILE I am still
> connected to dbtemp.
>
> If dbtemp does not exist I need to create it.  The problem is dbi needs to
> connect to a database even to create another one.  So what/how do I
connect
> to initially to create that first database?
>
> I realize, for geeks (myself included), that you could simply create the
db
> manually and then install the program.. but the program is to be usable by
> the layperson.. which means that there is a chance they don't know
anything
> about mysql other than the guy on tech support said it's installed on the
> server.
>
> How do I connect to mysql without connecting to a database?
>
>
> John
>
> -----Original Message-----
> From: Eric Fitzgerald [mailto:[EMAIL PROTECTED]]
> Sent: Friday, February 16, 2001 1:21 PM
> To: John Tsangaris; [EMAIL PROTECTED]
> Subject: Re: Perl DBI
>
>
> Connect to the mysql database if you have access.  It always exists.
>
> ----- Original Message -----
> From: "John Tsangaris" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 16, 2001 1:58 PM
> Subject: Perl DBI
>
>
> > Is it possible to connect to mysql without connecting directly to a
> > database, check to see if a particular database exists, and if it
doesn't
> > exist create it?
> >
> > I have not been able to find a way of connecting to mysql without having
a
> > database already (I want perl to be able to make the db.. not have it
> > already made before hand.)
> >
> > tia
> >
> > John
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> >    http://www.mysql.com/manual.php   (the manual)
> >    http://lists.mysql.com/           (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> >
> >
>
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to