Re: Creating Mysql DB with PHP
- From: "Tony" <tony23.no@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 8 Jun 2005 10:41:13 -0700
"MS" <nospamplaesegr8t_ukuk@xxxxxxxxxxx> wrote in message
news:d86siv$2o3$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>> If someone else has a server with MySQL on it already, they will also
>> have
> a
>> userID and password for that MySQL server. All you need to do is get that
>> information from them and use that information to connect to the
>> database.
>
> I am only going by what I have to do when setting up a new database.
>
> 1 goto Cpanel > Mysql Databases
> 2 Create a new database
> 3 create a user for that database incl password
> 4 then its on to PHPMyAdmin to create tables etc..
>
> If i dont do steps 1 to 3 i can not connect to the database via php.
> even if i only do steps 1 and 2 i can not connect.
>
> I'm sure i must be missing something somewhere, but im not sure what or
> where.
OK - that helps get a perspective. And yes, you are missing something: it
has to do with the manner in which you are setting up your database.
When you install a MySQL server, you initially install a user named "root".
That user initially has full privileges, including the ability to create
other users. Generally, that account is used by the database
administrator(s) to set up individual user accounts.
When you create a MySQL database in CPanel, Cpanel is accessing the server
with an existing user account that has the privileges to be able to create
other users. That account was most likely set up by the system admin when
you signed up for the hosting service. If you had that userID and password,
you could probably use it to access the database, as well as the user you
created along with the database.
The ultimate point being: you HAVE to have a userID and password already,
even to create other userIDs. The only exception to this (that I'm aware of,
at least) is during the initial setup of MySQL, when you have to define the
'root' user.
The practical end of all this is that anyone who would be installing your
program would already have a userID & password for MySQL.
The biggest potential problem you face is that their userID would not have
privileges to create a database, in which case the attempt to create the
database would fail. You would have to provide some checking for that, and
offer instructions on what to do in that case (which would be to create the
database manually).
Another potential problem you face is that the database has already been
created by the user before running your setup script. Again, you would have
to do some checking for that, and if the database exists, you would skip the
database creation process and move along to the table creation & population.
I would recommend a failsafe check confirming that the user really wants to
do this, however, on the odd chance that they may already have a database
with the same name in use.
Given what you are trying to accomplish, I would strongly recommend getting
a better grounding in MySQL. I don't know of any web tutorials online other
than the official stuff at the MySQL website, but I'm sure there are
plenty - try www.w3schools.com for starters. Also, I have found the book
"PHP 5 / MySQL Programming for the Absolute Beginner" to be a really good
start - and since it includes instructions to install a MySQL server, it
should help you learn your way around from the ground up.
Hope that's some help -
.
- 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
- 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: Emailing a file
- Next by Date: Re: WHat kind of value is this?
- Previous by thread: Re: Creating Mysql DB with PHP
- Next by thread: Re: Creating Mysql DB with PHP
- Index(es):
Relevant Pages
|
|