Re: Creating Mysql DB with PHP
- From: "Tony" <someone@xxxxxxxxxxxxx>
- Date: Tue, 7 Jun 2005 10:09:18 -0700
"MS" <nospamplaesegr8t_ukuk@xxxxxxxxxxx> wrote in message
news:d84cn0$ftk$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> > My current DB is on my Linux Server, and I don't have access to any
> MYSQL
>> > directories.
>> > So I think what you are suggesting is not viable for me.
>> >
>> > would another possibility be to...
>> >
>> > create a PHP file to run SQL that would create the DB and all the
> tables.
>> > This I don't see a problem with.
>>
>> You were also asking to duplicate data, though - and that could present a
>> problem, depending on how much data you're copying. If it's not too much,
>> you may be ok.
>
> I honestly dont think the amount of data to be created via mysql_query()
> would pose a problem.
I've worked with databases so big that trying to copy them via a dump like
that took over 12 hours, then crashed out. But they had many thousands of
records. I'm offering that more as a heads-up to a potential problem, but it
won't be an issue unless the database being copied gets quite large.
If you're talking a few dozen, or even a few hundred, records, it's not an
issue.
>> As for setting up the database & tables, that's pretty straightforward -
>> just use mysql_query() to send the appropriate queries to the database.
>> In
>> fact, you should probably use that for creating the database, too, since
>> mysql_create_db is deprecated - it's better practice to get into.
>>
>> > but how do you set the connection values...'mysql_user' &
> 'mysql_password'
>> > within php and relate this to the DB that is to be created.
>> >
>> > mysql_connect('localhost', 'mysql_user', 'mysql_password') ;
>>
>>
>> basically, you just set them either as strings in the command, or as
> string
>> variables. So for user="root" and password="rootpw":
>>
>> mysql_connect('localhost',' root','rootpw');
>
> I am presuming that when one wants to use
>
> mysql_query("CREATE DATABASE `testdb`")
>
> Firstly I would need to connect via...
> mysql_connect('localhost',' root','rootpw');
>
> As i do with all my other queries.
>
> But how do you associate the user (root and rootpw) to the database. this
> i
> usually do within Cpanels MySQL Databases management system. Not done it
> in
> php code before.
You use the userID and password of a user that is already created on the
system.
If this is being installed on someone else's system, then you need to
provide some way for them to enter that information. You could do it like
PHPMyAdmin - where the end-user modifies a configuration file and enters the
info, or you could make a form that accepts the information and passes it to
the installation script.
.
- Follow-Ups:
- Re: Creating Mysql DB with PHP
- From: MS
- Re: Creating Mysql DB with PHP
- References:
- Creating Mysql DB with PHP
- From: MS
- Re: Creating Mysql DB with PHP
- From: Tony
- Re: Creating Mysql DB with PHP
- From: MS
- Re: Creating Mysql DB with PHP
- From: Tony
- Re: Creating Mysql DB with PHP
- From: MS
- Re: Creating Mysql DB with PHP
- From: Tony
- Re: Creating Mysql DB with PHP
- From: MS
- Re: Creating Mysql DB with PHP
- From: Tony
- Re: Creating Mysql DB with PHP
- From: MS
- Re: Creating Mysql DB with PHP
- From: Tony
- Re: Creating Mysql DB with PHP
- From: MS
- Creating Mysql DB with PHP
- Prev by Date: Re: Reading an XML dataset, an idiots guide
- Next by Date: Re: PHP PROGRAMMING HELP??
- Previous by thread: Re: Creating Mysql DB with PHP
- Next by thread: Re: Creating Mysql DB with PHP
- Index(es):
Relevant Pages
|