Home arrow PHP arrow Page 2 - Doing More With phpMyAdmin (Part 1)

Start Me Up - PHP

You might not know this, but you can do a lot more with phpMyAdmin than just create tables and insert records. This first in a two-part series takes a look at some of the other features hidden under the hood of this popular PHP application, explaining how it can be used to secure access to the MySQL server, manage multiple servers, manipulate user privileges, view reports on server activity, and export MySQL data into different formats.

  1. Doing More With phpMyAdmin (Part 1)
  2. Start Me Up
  3. Locking the Doors
  4. The More the Merrier
  5. A Perfect State
  6. The Privileged Few
  7. In and Out
  8. Mood Ring
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 148
October 27, 2003

print this article


In order to get started with phpMyAdmin, you'll need a working PHP installation (I'm currently running PHP 4.2.3), a MySQL database server (I'm running MySQL 4.0.14) and a copy of the latest release (currently version 2.5.3) of the package; you can download a copy from http://www.phpmyadmin.net/

The developers of phpMyAdmin have been considerate enough to maintain two versions of this popular software, one for servers that have been configured to parse PHP files with the ".php3" extension (a widely observedlegacy) and another for those using the newer ".php" extension. You should select the version that is compliant with your Web server's configuration.

Setting up the package is pretty simple. The first step is to uncompress the source archive into a directory under your Web server (mine is called "medusa" here) root.

$ cd /usr/local/apache/htdocs/

$ tar -xzvf /tmp/phpMyAdmin-2.5.3.tar.gz

This should create a directory named "phpMyAdmin/".

After checking to make sure that your Web and MySQL servers are up and running (you'd be surprised how often even experienced developers forget to do this at times), you can try accessing the application, by popping open your Web browser and navigating to the URL http://localhost/phpMyAdmin/. Here's what you might see.

"So, what's that error all about," you ask?

Simple - the software isn't configured yet. Let's do that next.

phpMyAdmin is configured via a single configuration file, "config.inc.php" (or "config.inc.php3"), located in the application folder. Open it in your favourite text editor and take a quick look at it. If you read the comments, you'll see that it allows you to configure almost every aspect of the application.

The first thing you usually need to configure is the $cfg['PmaAbsoluteUri'] variable - this stores the Web server URL to the phpMyAdmin installation directory. Assuming an installation directly under the Web server root, you can set this as follows:

$cfg['PmaAbsoluteUri'] = 'http://localhost/phpMyAdmin/';

While this will get rid of the error message displayed on the application's opening page, you will still not be able to view databases or tables on the MySQL server (go on, try it and see for yourself). This is because the application does not yet know where to look for the MySQL server, or have access privileges for the same. Move on to the next section of the configuration file, which allows you to define the server configuration variable $cfg['Servers'].

I'll begin with showing you how to configure phpMyAdmin for a single server. In order to do this, you will need three values: the host name or IP address of the machine hosting the MySQL server, the user name to access the server (note that this is *not* the same as the UNIX user name) and the corresponding password. If the server is running on a non-default port, you'll need that information too.

If you're running phpMyAdmin as an administrator, you can set the user name to "root", or an equivalent privileged user in MySQL. If, on the other hand, you're configuring a "limited-view" phpMyAdmin, which is to be used only by a specific user, you can use that user's user name and password instead.

Once you have all this information, make sure that your configuration file contains the following (I'll assume here that the server is "localhost", the user is "root", and the root password is "secret", with the server running on its standard port):

$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname
$cfg['Servers'][$i]['port'] = ''; // MySQL port - leaveblank for default port
$cfg['Servers'][$i]['socket'] = ''; // Path to the socket -leave blank for default socket
$cfg['Servers'][$i]['auth_type'] = 'config'; // Authentication method
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'secret'; // MySQL password

A small note here on the "auth_type" parameter above. I have set this value to "config", which indicates that phpMyAdmin should use the credentials provided in this configuration file to access the database server. Note that this is a potential security hole, as the database server becomes vulnerable if the configuration file falls into the wrong hands. I'll be explaining how to solve this problem shortly.

Once you've made your changes to the file, save it and try navigating back to http://localhost/phpMyAdmin/ in your browser. This time, if you've configured it correctly, you should be able to see a list of databases on the MySQL server in the drop-down box at the top left corner. Select a database from the list and you'll see a list of tables present in it.

Cool, huh? This is just the beginning.

>>> More PHP Articles          >>> More By Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: