coldfingertips has asked for the wisdom of the Perl Monks concerning the following question:

Two questions on MySQL and CGI.

I have a few small CGI scripts that write to and read from the database now but I need to create the database via PHPAdmin myself. There are some scripts out there that actually set up the database itself AND the tables, not just the tables.

How can you do this? How would you get the user's database name, assign privelegdes, setup the MySQL database, etc?

Secondly, is there a way to make the char limit on any of the columns infinite to the point where there are no coded limits? I store URLs sometimes and some are longer than others, some exceeding 150 characters. If I set varchar(200) for everything, that's setting up some dead weight, isn't it? Is there a way to set up the column without imposing a limit? And if so, how bad is this in terms of security?

Replies are listed 'Best First'.
Re: setting up mysql database name
by diotalevi (Canon) on Dec 09, 2005 at 20:17 UTC
    1K is a practical limit for URL length. Browers choke on URLs longer than that.
      Thanks for that info, I didn't know that.

      When you create it for 1000, does that make each column UPTO 1000 bytes or does it actually set each column at 1000 whether it has that much data or not?

        I said 1K, not 1000. 1K is typically 1024 when you're in a programming context (its metric 1000 for everyone else).

        If you use varchar(), it will only allocate the space it needs.

Re: setting up mysql database name
by jZed (Prior) on Dec 09, 2005 at 21:00 UTC
    You will need to make an inital connection to an existing MySQL database and then issue the appropriate CREATE and USE commands to set up your new database. You can either make the initial connection to a database of your own that you know already exists, or possibly to one of the system databases.