
phpMyAdmin is probably the most well-known database management tool for MySQL databases. Besides allowing the administrator to browse the objects in the database through a graphical web frontend, phpMyAdmin also mase easy to carry out many common DBA maintenance tasks. This post explains how to install and configure phpMyAdmin on a Linux distro.
1. phpMyAdmin installation pre-requisites
Check that PHP version 5 or above is installed on the system:
1 2 3 4 5 6 |
$ php -v PHP 5.4.4-9 (cli) (built: Oct 26 2012 13:00:59) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies |
Check that MySQL version 5 or above is installed on the system:
1 2 3 4 5 6 7 |
$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 811 Server version: 5.5.28-1 (Debian) |
and, of course, there must be also an Apache web server installed on the system.
PHP5 modules
If a PHP interpreter was not previously installed on the system where phpMyAdmin is to be installed, it is advisable to perform a PHP installation from source. The “configure” command below ensures that all PHP modules required by phpMyAdmin will be included in the executable:
1 2 3 4 |
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-bz2 --with-zlib --enable-zip --enable-mbstring --with-mcrypt |
If some of the required modules has not been compiled into the PHP executable, phpMyAdmin will display the following error messages:
- GZip – GZip compression and decompression requires functions (gzencode) which are unavailable on this system.
- Bzip2 – Bzip2 compression and decompression requires functions (bzopen, bzcompress) which are unavailable on this system.
- ZIP – Zip decompression requires functions (zip_open) which are unavailable on this system.
- ZIP – Zip compression requires functions (gzcompress) which are unavailable on this system.
2. Download and install phpMyAdmin under the Apache DocumentRoot
The root of our web server is defined by the “DocumentRoot” directive in the apache configuration file:
1 2 3 4 |
# grep DocumentRoot /usr/local/apache2/conf/httpd.conf DocumentRoot /usr/local/apache2/htdocs |
The latest phpMyAdmin release can be downloaded from www.phpmyadmin.net. At the time this post is being written, the most recent version is 3.5.5; the file available for download is phpMyAdmin-4.1.8-all-languages.tar.gz (8 MB). Once downloaded, the file is uncompressed under the DoucumentRoot, and renamed to “phpmyadmin”:
1 2 3 4 5 |
# cd /usr/local/apache2/htdocs # tar xvfz phpMyAdmin-4.1.8-all-languages.tar.gz # mv phpMyAdmin-4.1.8-all-languages phpmyadmin |
NOTE: Instead of renaming the directory, a symbolic link could be created, to keep the reference to the installed version:
1 2 3 |
# ln -s phpMyAdmin-4.1.8-all-languages phpmyadmin |
3. Create a phpmy user to protect the phpmyadmin directory
Create a unix user “phpmy”:
1 2 3 4 |
# adduser phpmy # passwd phpmy |
Check the group name used by Apache:
1 2 3 4 |
# grep APACHE_RUN_GROUP /etc/apache2/envvars export APACHE_RUN_GROUP=www-data |
Set “phpmy” as the owner, and the apache group above as the group of the “phpmyadmin” directory:
1 2 3 4 |
# cd /usr/local/apache2/htdocs # chown -R phpmy.www-data phpmyadmin/ |
4. Edit the phpMyAdmin configuration file config.inc with the help of the wizard
The phpMyAdmin configuration file “config.inc” can be manually edited, but it is also possible to use the configuration wizard. To do this, an empty configuration file is first created:
1 2 3 4 5 6 7 |
# cd /usr/local/apache2/htdocs/phpmyadmin/ # mkdir config # chmod o+rw config # cp config.sample.inc.php config/config.inc.php # chmod o+w config/config.inc.php |
Next, point the browser to the configuration wizard at the URL “http://localhost/phpmyadmin/setup/index.php” (if the server where the installation is being carried out is not the same system where the browser is running, replace “localhost” with the IP address or server name):
Next, click on “New Server”:
In this form, fill in the field “Verbose name of this server”, leaving the default value of the other fields, and click on “Apply”:
- Verbose name of this server – For instance, “WordPress & Joomla Database”
After this step, several warning will be displayed about the use of SSL, Blowfish secret, etc. They can be ignored for now. Once the configuration is done, move the “config.inc” file under the phpmyadmin directory, and delete the “config” directory:
1 2 3 4 5 6 |
# cd /usr/local/apache2/htdocs/phpmyadmin/config # cp config.inc.php .. # cd .. # rm -rf config |
5. Access phpMyAdmin
Finally, we can use the url “http://localhost/phpmyadmin/index.php” to access the login screen:
On accessing the login form, a message “Cannot load mcrypt extension. Please check your PHP configuration.” might be displayed. This happens if the PHP interpreter used was not compiled with the mcrypt module. In this case, we must install the libmcrypt and libmcrypt-devel packages, and compile again PHP from source, using the option –with-mcrypt.
The username and password to enter in the login form is the mysql administration user (usually “root”) and password we use to connect to mysql from the command line. Once logged in, we can access all the functionality offered by phpMyAdmin to manage our data bases from a browser:
—
Index of posts related to MySQL
—