Preparing MySQL for the PHP tutorials

Discussion in 'Web Design & Programming' started by RHochstenbach, Mar 8, 2011.

  1. RHochstenbach

    RHochstenbach Administrator Staff Member

    Likes Received:
    26
    Trophy Points:
    48
    I would strongly recommend every MySQL user to install phpmyadmin on your server for easily managing your database.

    You can create a database, create users, assign user rights to your databases and add tables to your databases. In this example, create a database called 'tutorial'. Now create a user called 'student' and the password 'learning'. Now assign all rights for the user 'student' to the database 'tutorial'.

    Before you can add data to your database, you need to create tables. Each table contains information like a regular table. Each column has a name and can contain specific variables. TEXT means any kind of characters, INT means an integer like an ID, BOOLEAN means a YES/NO value and DATE means a data stored in YYYY-MM-DD format.

    Each item in your database should have a unique value, so there can't be any duplicate values. A column that may only contain unique values can be set as the Primary Key. This can be a customer number or a unique ID. If you don't have such numbers, just create a column called ID.

    Create a table in your database called 'addresses' with 4 columns. Call column 1 'id' and set the data type to INT with a length of 5. Enable AUTO_INCREMENT on the id_column to automatically assign a higher number to each new item. Column 2 should be called 'name', 3 should be 'address' and 4 should be 'phone'. Column 2 -4 should have data type TEXT.

    Now assign the Primary Key to the column 'id'.
     

Share This Page