creating a database file..

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

creating a database file..

Post by gavinbsocom »

I'm unsure on how to create a database file? I have been reading different tutorials and I just dont understand it. I have mysql installed on my computer and I will also have it on my web hosting service in about a week. The main purpose of this is database is to make a user login / register. So do I open up a blank page in notepad and call it database1.db?
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

try googling for PHPMyAdmin, which can be used for Database manipulation, creation, deletion etc..
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Re: creating a database file..

Post by JAM »

gavinbsocom wrote:I'm unsure on how to create a database file?
...
So do I open up a blank page in notepad and call it database1.db?
Forgive me if I do not quite understand the issue, but what exactly do you mean by 'database file'?
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post by gavinbsocom »

I'm trying to say a file or a database file or a database that will hold a user name and password...I just dont understand how to create one or what do I do to get one?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

ok, go in your mysql directory, and then go into the DOCS directory within it. you will see a MySQL manual. Skip down to section 3.1 and it teaches you how to use mysql from there.

if you are wanting to know how to create a database from within php on the fly, that is a totally different subject.
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post by gavinbsocom »

so I create the database and then have php install it? Infolock your saying I could create the database from php code but it would be easier to create the database and then have the php code call the database?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

so I create the database and then have php install it? Infolock your saying I could create the database from php code but it would be easier to create the database and then have the php code call the database?
well, the easiest way possible is to just create teh database from within MySQL itself. As i said, there is a manual inside the MySQL directory that you installed it to that tells you pretty indepthly how to do this.

as far as calling the database, php is by far the easiest way. check this link out :

http://www.php.net/function.mysql-connect

it gives you some very nice functions and methods of how to connect. as far as creating the user authentication program, you may want to hold off on doing that until you learn how to create databases/tables with mysql, and then learn how to pull that info from mysql.

after you will need to learn about $_POST as i'm sure you will be typing the username/password in a post field. give me a few and i'll post a sample script i wrote a few months(maybe a year?) ago and it may give you a pretty good insight.


here's the link :
viewtopic.php?t=3649&highlight=
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post by gavinbsocom »

Ok, but check this out,,,this isf romt he manual...this is what i dont understand....


To connect to the server, you'll usually need to provide a MySQL user name when you invoke mysql and, most likely, a password. If the server runs on a machine other than the one where you log in, you'll also need to specify a hostname. Contact your administrator to find out what connection parameters you should use to connect (that is, what host, user name, and password to use). Once you know the proper parameters, you should be able to connect like this:

shell> mysql -h host -u user -p
Enter password: ********


Where do i type that shell statement or w/e it is? In notepad? in command prompt? in what?
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Are you running Windows, if so start here:
http://www.mysql.com/doc/en/Windows_running.html

Mac
gavinbsocom
Forum Commoner
Posts: 71
Joined: Tue Sep 30, 2003 9:51 pm

Post by gavinbsocom »

Yes, I am running windows Xp pro. Ill give that a whirl and let you know how it worked out.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

Like I said, if you would read the manual that's found in your MySQL directory, you would be able to do this so much easier :)

i'm not trying to be rude, but that manual gives you STEP BY STEP instructions on how to do the things you need.

but if you need a quicker response, here :

1) Clicks Start
2) Click Run
3) type CMD and press enter
4) type cd \ and press enter. this will take you to the root of C:\
5) type cd mysql
6) type cd bin
7) type mysql -u root


now, this will just get you into mysql. you are going ot need to setup another username that will ONLY have read/write/create/drop options on particular databases or tables.

all this is covered in the manual that's in your mysql/doc directory

if you want more information on function calling from within php, i suggest you read the link i posted above for calling convensions

hope that helps :P
Post Reply