To create and administer MySQL databases, you need to use database administration software. The most popular MySQL administration software is phpMyAdmin. It's written in PHP and runs in the browser. It provides a user interface that greatly simplifies your interactions with MySQL.
phpMyAdmin is a free, open-source Web application written in PHP. You can download and install phpMyAdmin on your local machine to access MySQL databases on your machine or on other machines over a network. Most Web hosting companies provide phpMyAdmin for you to use when accessing your databases on their computers.
You must install MySQL and PHP before you can install phpMyAdmin. If you installed XAMPP, phpMyAdmin was probably installed during the installation process. If you intalled PHP and MySQL separately, you must install phpMyAdmin separately. The following sections provides instructions for downloading, installing, and testing phpMyAdmin by itself, after you have installed your Web server, MySQL, and PHP.
You can obtain phpMyAdmin by downloading it from the phpMyAdmin Web site. Follow these steps:
To install phpMyAdmin, you unzip the file you downloaded and you store the files in the directory where your Web server looks for Web page files (the document root). You then configure phpMyAdmin to communicate with your MySQL installation. To install phpMyAdmin, follow these steps:
cd phpMyAdmin.
Figure 3-5: The phpMyAdmin Setup Web page.
Figure 3-6: The phpMyAdmin Add Server Web page.
After you install phpMyAdmin, you want to test it to ensure that it installed properly and is working correctly. To test phpMyAdmin, open a browser. Go to the index.php file in your phpMyAdmin directory. For example, you might type:
localhost/phpMyAdmin/index.php
The phpMyAdmin main Web page appears. It displays information about your MySQL installation, such as its version. Figure 3-7 shows the phpMyAdmin main Web page.
Figure 3-7: The phpMyAdmin Main Web page.
Notice that the left pane shows a field named Databases. The drop -down list contains all the databases that currently exist.
The top of the left column in the main section of the Web page shows the version of the MySQL server that is running. Below that, the page shows which user is running phpMyAdmin, (in this case, root).
phpMyAdmin allows you to administer your MySQL databases.
When you test phpMyAdmin, you might see an error message similar to the error message shown in Figure 3-8.
Figure 3-8: A phpMyAdmin Error Message.
This error message states that phpMyAdmin access to the MySQL server is denied to the user specified in the phpMyAdmin configuration file. In most cases, the problem is an incorrect account name or password. You can see what your current account name and password are by viewing the config.inc.php file located in the phpMyAdmin directory.
Open the configuration file in a text editor. Scroll down to the section for your server that looks similar to the following:
/* Servers configuration */ $i = 0; /* Server localhost (config:root) [1] */ $i++; $cfg['Servers'][$i]['host'] = 'localhost'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['compress'] = false; $cfg['Servers'][$i]['auth_type'] = 'config'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = 'secret'; /* End of servers configuration */
Check that the parameters are correct. The account name in this file is root, and the password is secret. If any parameters are incorrect, edit the file to correct them. Save the file and restart phpMyAdmin again.
Notice that the error message in Figure 3-8 includes a small question mark (?) after the heading. If you click the question mark, the appropriate MySQL documentation page opens.