Becoming Familiar with Databases in phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's familiarize ourselves with databases and phpmyadmin.
  3. From this phpMyAdmin screen, we have access directly to the database demo1234_members, listed here. A database consists of one or more tables, and it is in the tables that database information is recorded. This particular database has two tables called details and information, and they are listed here. Click the database name just above them.

    phpma-familiar-frame02_1

  4. From here we can see more information about the tables contained in the database, as well as perform several actions.

    phpma-familiar-frame03_1

  5. We can Browse a table to see the individual records.

    phpma-familiar-frame04_1

  6. We can see the Structure of a table and perform certain actions.

    phpma-familiar-frame05_1

  7. We can Search through a table for specific keywords.

    phpma-familiar-frame06_1

  8. We can Insert new rows (or fields) into a table.

    phpma-familiar-frame07_1

  9. We can Empty  (or delete) the contents of a table.

    phpma-familiar-frame08_1

  10. Or we can Delete (or drop) an entire table altogether.

    phpma-familiar-frame09_1

  11. We can alternatively click here to view the database Structure.

    phpma-familiar-frame10_1

  12. We can open an SQL Query window for entering direct queries to the database.

    phpma-familiar-frame11_1

  13. We can click here to perform a Search.

    phpma-familiar-frame12_1

  14. This also opens a SQL Query window, but provides an easier step-by-step way to make queries.

    phpma-familiar-frame13_1

  15. We can Export databases to our local computer.

    phpma-familiar-frame14_1

  16. We can Import previously exported databases.

    phpma-familiar-frame15_1

  17. … and we can perfom a number of other operations like creating new tables, copying or renaming databases from here.

    phpma-familiar-frame16_1

  18. Now let's look at the structure of the details table.

    phpma-familiar-frame17_1

  19. The structure of the details table lists all the table's fields, along with the type of field, etc.

    phpma-familiar-frame18_1

  20. Here it tells us that the id field is the Primary Key field.

    phpma-familiar-frame19_1

  21. If you want further help with SQL, you can click here…..

    phpma-familiar-frame22_1

  22. … or help with phpMyAdmin, you can click here.

    phpma-familiar-frame23_1

  23. Clicking here is another way of opening the SQL query window.

    phpma-familiar-frame24_1

  24. … and clicking here logs you out of phpMyAdmin.

    phpma-familiar-frame25_1

 

Deleting Fields from Database Tables with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to delete fields from database tables.
  3. Select the details table here.

    phpma-delfield-frame3_1

  4. Let's delete the city field.

    phpma-delfield-frame4_1

  5. Click the Delete (or Drop) icon and click Yes to confirm.

    phpma-delfield-frame5_1

  6. That's it! We've successfully deleted the city field from our database table.

 

Modifying Fields in Database Tables with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to modify fields in database tables.
  3. Select the details table here.

    phpma-modifyfield-frame3_1

  4. Let's modify the address field. Click Change  icon.

    phpma-modifyfield-frame4_1

  5. Make the changes you want, then click Save.

    phpma-modifyfield-frame6_1

  6. That's it! We've successfully changed the name of the address field to city.

    phpma-modifyfield-frame7_1

 

Inserting Fields into Database Tables with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to insert fields into database tables.
  3. Select the details table here.

    phpma-insertfield-frame03_1

  4. In this case, let's choose to add an address field AFTER the name field.

    phpma-insertfield-frame05_1

  5. Click Save when finished.

    phpma-insertfield-frame11_1

  6. That's it! Our details table now has a new address field.

    phpma-insertfield-frame12_1

 

Copying a Database Table with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to copy a database table.
  3. Click the database table you wish to copy.

    phpma-copy-frame3_1

  4. Then click the Operations tab.

    phpma-copy-frame4_1

  5. When copying a table, you can choose to copy the table structure only, the data only, or both. Enter a name for the new table here, then click Go.

    phpma-copy-frame5_1

  6. Copying a table actually creates a new table altogether (that's identical to the one we're copying)….. so we have to give a name for the new table.
  7. That's it! A new table has been created, and it is a perfect copy of the original. Both tables are now listed here.

    phpma-copy-frame6_1

 

Renaming Database Tables with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to rename database tables.
  3. Click the database table you wish to rename.

    phpma-rename-frame3_1

  4. Then click the Operations tab.

    phpma-rename-frame4_1

  5. Enter a new name for the table here.

    phpma-rename-frame6_1

  6. Then click Go.
  7. That's it! The information table has been renamed infotable, and is listed here.

    phpma-rename-frame7_1

 

Exporting Databases and Tables with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to export a database.
  3. Click the database you wish to export here.

    phpma-export-frame03_1

  4. Then click the Export button.

    phpma-export-frame04_1

  5. In this case, we want to export the entire database in SQL format, so we can easily import it later. This is a good way to backup your database.
  6. Be sure to check any options you want before proceeding.

    phpma-export-frame06_1

  7. Check the Save as File checkbox, then click Go.

    phpma-export-frame11_1

  8. That's it! The demo1234_members database has been exported to our local computer.
  9. If you only wanted to export a table, and not the entire database, follow these steps:
  10. Remember that exporting tables only exports the selected tables within a database, whereas exporting a database will export all tables as well (provided they're all selected).
  11. That's it! The details table has been exported to its own file.

 

Importing Databases and Tables with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to import a database.
  3. Click the database you wish to import here.

    phpma-import-frame03_1

  4. Let's assume the data in our details table is corrupt, and we want to import a saved (exported) copy of the data.
  5. Therefore, let's first delete the existing details table from our database.

    phpma-import-frame05_1

  6. Now let's import the saved copy of our database, which includes the details table.

    phpma-import-frame07_1
     
    phpma-import-frame09_1
     
    phpma-import-frame14_1

  7. That's it! The demo1234_members database has been successfully imported, as indicated here.

 

Creating Tables in a Database with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to create a table within a database.
  3. Select the database here.

    phpma-createtable-frame03_1

  4. Enter a Name for your new table.

    phpma-createtable-frame04_1

  5. Then enter the number of fields this new table is to have. Click Go.

    phpma-createtable-frame05_1

  6. Now enter the details of each field within the new table.

    phpma-createtable-frame07_1

  7. The first field will be called id, and it will be an integer that's 4 characters in length.

    phpma-createtable-frame08_1

  8. We also want this first field to be the Primary key that will be automatically filled in (auto_increment) when new entries are added to the table. Selecting this option makes the id field the Primary key in the table.

    phpma-createtable-frame13_1

  9. The remaining fields will be CHAR (character) fields. Be sure the length is set long enough to accomodate the fields.

    phpma-createtable-frame17_1

  10. When finished, click Save.

    phpma-createtable-frame22_1

  11. That's it! Our new table (details) has been successfully created within our database(demo1234_members) as indicated here.

    phpma-createtable-frame23_1

 

Searching Through a Database with phpMyAdmin

 

  1. This tutorial assumes you've already logged in to phpMyAdmin.
  2. Now let's learn how to use the Search feature.
  3. Click the database you wish to search here.

    phpma-search-frame03_1

  4. Then click the Search tab and enter words or values to search for in the database.
    phpma-search-frame04_1

  5. There are several options you can use to refine your search. This database only has one table (details), but if there were more, you could limit your search to specific tables here.

    phpma-search-frame05_1

  6. When ready, click Go to perform the search. This search found one match. Click Browse.

    phpma-search-frame06_1

  7. We can now make changes to the record that was found.

    phpma-search-frame10_1

  8. Click Go when finished.