Jump to content
xisto Community
iGuest

Any One Know How To Create A Database?

Recommended Posts

Well lets do this a couple of ways:

ONE With a script like the below PHP script:

<?php//quick database create database code without forum entry//define the variables for connection to database.$database="testdb"; //give it some kind of name here (the database)$user="username"; //you need a user name to use the database server$host="localhost";  //usually localhost$password="yourpassword";  //you will need a password for the database$connection=mysql_connect($host,$user,$password) [tab][/tab] or die("Couldn't connect to server, check your username and password!");mysql_query("CREATE DATABASE $database") [tab][/tab] or die("Couldn't execute query");         [tab][/tab] echo "Database $database has just been created for you!";                     ?>
If you copy the above code even with the comments and assign the proper values for the host, databasename, username, and password it will connect to the database and create a database named testdb. Now let try method

TWO

 

Go to the cPanel like below

 

Posted Image

 

Then after you click the MySQL Icon you will see this:

 

Posted Image

 

So there you go how to create a data base with or without a cPanel using script and without using a script by using the cPanel, the choice is yours.

Share this post


Link to post
Share on other sites

Hi i would like to create a database but i do not know how. Could some one please show me how.

<{POST_SNAPBACK}>

Very nice script...I say the same thing...

 

MySql is a free and very easy to use, easy to understand web-based database. The latest version is very user friendly, and you can even export your data as excel, edit it, and reinsert it into the database very easily, if you are more comfortable using that format. It is very well documented and I believe it has a support forum community as well. However, you'd need to know how to code it, write queries.

 

My overall suggestion to you is this. Search tHotscripts.com, sourceforge.net, etc. for a free script that does what you need your database to do (like drive an address book, website, customer database, blah blah). Basically, search for a PHP script and download it. And if you can spend a few bucks (between 20USD and up), you can find commercial scripts which tend to be much better written, efficient and visually appealing. This will give you a front-end to display your data and work with the database, possibly even an admin side so that even the most inexperienced computer user can use the software.

Share this post


Link to post
Share on other sites

like what kind of atributes? if you want to add a table (where you store info) do this:

$query="CREATE TABLE  `[table name]` ( `[column name]` [data type] ,);";mysql_query($query);

for instance:

$query="CREATE TABLE  `contacts` ( `name` VARCHAR( 20 ) `phone number` VARCHAR( 20 ));";mysql_query($query);

Share this post


Link to post
Share on other sites

Your database is mostly an area where you are going to store cata that will change over time and need frequent updates or even new data altogether, but in order for it to be of any value it must have as little a one table that contains some sort of structure.Take for example you want a database that holds all your household items with serial numer if they have such , a description of the itms, other attributes of the item such as cose, or its appraised value and so on and this database has all this stuff so in the event that you have a disaster or theft you can bring up the information and let the insurance company and police (if it were a theft or robbery.You would need a table that had such fields as item, color, description, phptograph if any, serial number if any, cost or value, and so on. So you have tables for each of these and the data type needs to be defined within the table.So you name a database lets say mystuff (use the SQL query CREATE DATABASE 'mystuff' ), then it would have a table which you use to store your stuff kinda like: CREATE TABLE 'inventory' ('itemNumber' INT (4) AUTO_INCREMENT,'item' VARCHAR (40) NOT NULL,'value' VARCHAR (15),'color' VARCHAR (10) ,'description' VARCHAR (255),'serialnumber' VARCHAR(50),'date_aquired' DATE,PRIMARY KEY (itemNumber))of course this is just a made up example but I thinkyou should be able to get the idea, your real database might have hundreds of tables, but you need to figure out what all you want in a database and then set them all up, you might want to try a search for MySQL tutorials or SQL tutorials and learn a little about just what you want a database to do for your circumstances.

Share this post


Link to post
Share on other sites

To make a database you need a ftp. After you have a ftp please look for the install. Open the install and fill in the required info. After you do that start the database and see if it is working. If it is not working then please post for further help. This works for appace and if you need help with something else PLEASE tell me right away I am really good with this. ;)

Share this post


Link to post
Share on other sites

To make a database you need a ftp. After you have a ftp please look for the install. Open the install and fill in the required info. After you do that start the database and see if it is working. If it is not working then please post for further help. This works for appace and if you need help with something else PLEASE tell me right away I am really good with this. ;)

1064329830[/snapback]


That's not true - FTP doesn't have anything to do with the database, unless you're uploading the actual mysql binaries to your account for upgrades. To create a database, phpMyAdmin is sufficient, or if you're a power user - you have to use the command-line client of MySQL from your shell. Once again, whether it's apache or some other httpd, I've never heard of FTP being used to create databases... That's certainly a first. Try not to spread around disinformation like this.

Share this post


Link to post
Share on other sites

i've noticed that at least for me, phpmyadmin cannot create new databases, I have to use the other MYSQL script in cpanel. However, if I made a database and dropped it, phpmyadmin can recreate it. Dunno why, or if this is an issue for anyone, but it's slightly annoying to me.~Viz

Share this post


Link to post
Share on other sites

i've noticed that at least for me, phpmyadmin cannot create new databases, I have to use the other MYSQL script in cpanel.  However, if I made a database and dropped it, phpmyadmin can recreate it.  Dunno why, or if this is an issue for anyone, but it's slightly annoying to me.

 

~Viz

1064329969[/snapback]

I think since phpMyAdmin is a cPanel plugin (I know you can get it stand-alone, I have a copy of it), the folks at cPanel disable making of a database through phpMyAdmin for some reason and make you create one through cPanel.

 

It's the same way on my paid host. You have to create databases and users in cPanel, but you can do everything else right in phpMyAdmin.

 

[N]F

Share this post


Link to post
Share on other sites

I thought the FTP method of creating a database was rather unique, I would like to see that happen it is far beyond my level of just using MySQL or PHP script. I have only been able to use it for uploading files to the server but when I learn how to use the FTP method I will have gone to the extrmes with coding.

Share this post


Link to post
Share on other sites

i use the easy way of cpanel ? or doesn't this host offer cpanel for mysql setup ?? cause i wish to run a games arcade forum with high scores (one of the most comprehensive on the net) :Pso i really hope it's not that hard.. cause i did have luck on another host.. but they didn't like my .htaccess file which was really annoying.and phpadmin is for just using your mysql database AFTER you have created your database... like i know that much :o

Share this post


Link to post
Share on other sites

A database consists of tables.To create tables you should begin with data analysis, or relational model analysis.This analysis is very useful when you want decompose the data into appropriate tables.Begins with relational diagram, identiy is-a , has-a, and other relationships between objects.For example: a department has one or more employees, a department has at most one manager.is-a relationship is like subclassing in programming term.After you have constructed the diagram, you then begin decompose it into tables using standard rules.example: when A involved in many-to-one relationship C with B , then you create 2 tables for A separately, and a table for the relation C separately, B is now absorbed in the relation C, all the attributes,keys of B are combined with C.example to create a table: create table C(attribute1 datatype1, attribute2 datatype2,...) A many-to-one relation to C when some element of A is mapped to the same one element of C, and each element in A is mapped to exactly one element in C.

Share this post


Link to post
Share on other sites

Ohhhh, very simple ...

 

First of all u need to specify the Database type ...

R u talking about MySQL, PostGRE, Access or what ???

 

Anywayz, I am assuming that u are asking for MySQL :

There are many possible solutions for this :

 

 

 

First Solution : SQL Query through PHPmyAdmin

 

Just go to PHPmyAdmin and u can create a new Database either my using the GUI Interface or u can insert the MySQL query ..

If u want to insert the DQL Query than, I am assuming that u want to make a database named samya.

Than here is ur Query :

 

CREATE DATABASE `samya` ;

Thats it ... u are done ....

 

Limitations :

Keep one thing in mind that, if u want to use this method than u must have the given ALL PRIVELEGES to the user otherwise, u might get an error e.g. NO Priveleges

 

Second Solution : Using PHP

 

This is more or less similar to First method ...

Use this Code :

 

mysql_create_db('samya');

Keep one thing in mind that before calling for this function, u must have already connected with the Database ...

 

U can can connect with the database using this function :

 

<?php

$dbhost = 'localhost';

$dbuser = 'username';

$dbpass = 'password';

 

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

?>

 

Place ur Databse username and Password into $dbuser and $dbpass

 

The value $dbhost is ur Host.

In more than 85% cases it is either :

localhost

127.0.0.1

However u may have a different value. Contact ur Hosting Provider for this purpose ..

If u know the MySQL server name and port number than u can insert this into $dbhost.

For example if the

MySQL server name is db2.mydomain.com and the

Port number is 3306 (it is also the default port number for MySQL)

then you you can modify the above code to :

 

$dbhost = 'db2.mydomain.com:3306';

However, this method also has the same limitation ......

i.e. u must have given the relevant Priveleges to the user ...

 

Third Solution : Through Administration

 

Still, there are a number of WebHosts who donot allow the creation of Database through phpmyadmin or through any PHP Script ...

This is aminly due to safety purposes ....

 

One of these examples in cPanel. In case of cPanel u need to create the database and add its users all in cPanel .....

 

For this, just open, ur cPanel, and than click : MySQL Databases.

After that, add a Database name, and Click Add New Database

That's it :o ....

 

Now u need to add a user to the Database ....

Just select a user from the Drop Down Button and click Add User to Database, or otherwise Create a new user and add it to Database .....

 

I dont think that u will face any problems now ...

If u still face any problem, than u can Post further in this topic ...

 

*** All Appreciations and Criticisms about this tutorial are welcome ***

 

Regards:

Samya Khalid

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.