Chapter 2. Working with phpMyAdmin

In this chapter, we will cover:

  • Exporting a database
  • Importing a database
  • Working with database rows and tables
  • Removing a table
  • Emptying a table

Introduction

In the first chapter and recipes, you were shown how to setup a database and establish users. The tool for driving this is called, phpMyAdmin.

phpMyAdmin is a popular, open-source tool that is a standard on most web hosts. Written in PHP, it enables you to handle all the administration of your MySQL database, keeping you from working in the command-line mode.

Here is an example of a command for setting up a new user:

CREATE USER 'jcookbookadmin'@'localhost' IDENTIFIED BY 'MyPassword';

or creating a database

CREATE DATABASE jbookdb;

or assigning privileges to it

GRANT ALL PRIVILEGES ON 'jbookdb' . * TO 'jcookbookadmin'@'localhost';

As you can see, attempting to remember all those commands is probably more than you want or need.

As Joomla! is primarily a database-powered system, from time to time you will need to know your way around phpMyAdmin for some of the tasks you may face.

One important item that phpMyAdmin can help you with is exporting your database. What this means is backing up your database and putting it in a safe place.

In later chapters, you will learn how to install and use tools to assist with backup and recovery; however in an emergency having knowledge of this tool is important.

This tool can also be dangerous and I STRONGLY RECOMMEND, you backup your database (using export) before you try anything. That way you can quickly restore it.

Before diving in, let's learn some terms that are used in describing databases.