Re: Creating Mysql DB with PHP



"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 -


.



Relevant Pages

  • Re: hitting the limits
    ... relatively straight forward MySql database. ... 10K visitors a month and an 80Mb database are nothing. ... heavily loaded server. ... But the connection will hang around until the garbage ...
    (comp.lang.php)
  • Re: Database connection error (re-post)
    ... MySQL is a database server, it is not a desktop database like Access, you have to work with directly ... FrontPage Resources, WebCircle, MS KB Quick Links, etc. ...
    (microsoft.public.frontpage.client)
  • Re: Confusion about database updates
    ... all connecting to the same database server. ... MySQL can easily handle many simultaneous clients. ... AlphaCluster all open multiple connections to a MySQL server running on ... Let the MySQL server do that when your client ...
    (comp.lang.java.databases)
  • Re: Using MySQL as the backend
    ... I need to learn MySQL, ... > the impression you're not familiar with the concept of a server DB. ... > doesn't need to have Access installed to access the database, ... >> install the server or maybe I have it installed but I just don't know how to ...
    (microsoft.public.access.tablesdbdesign)
  • Re: MySQL Insert Unicode Problem
    ... I'm trying to insert some data from an XML file into MySQL. ... The database server has to support Unicode, ...
    (comp.lang.python)