How to Install MySQL with phpMyAdmin on Ubuntu 12.04
Updated by Linode Written by James Stewart
DeprecatedThis guide has been deprecated and is no longer being maintained.
phpMyAdmin is a web application that provides a GUI to aid in MySQL database administration. It supports multiple MySQL servers and is a robust and easy alternative to using the MySQL command line client.
NoteThis guide is written for a non-root user. Commands that require elevated privileges are prefixed with
sudo. If you’re not familiar with the
sudocommand, you can check our Users and Groups guide.
Before You Begin
To check your hostname run:
hostname hostname -f
The first command should show your short hostname, and the second should show your fully qualified domain name (FQDN).
Update your system:
sudo apt-get update && sudo apt-get upgrade -y
Set up a working LAMP stack. Please see the LAMP on Ubuntu 12.04 guide if needed.
NoteIf you have installed the
php-suhosinpackage, there are some known issues when using phpMyAdmin. Please visit the Suhosin phpMyAdmin Compatibility Issues page for more information about tuning and workarounds.
Set up Apache with SSL, so your passwords will not be sent over plain text. To do so, go trough the SSL Certificates with Apache on Debian & Ubuntu guide.
sudo apt-get install mcrypt
sudo service apache2 restart
Setting Up phpMyAdmin
Install the current version of phpMyAdmin:
sudo apt-get install phpmyadmin
You will be asked which server to automatically configure phpMyAdmin for. Select the web server that you have installed. If you have more than one web server installed, select the best option for your deployment. Follow through the rest of the guided installer to set passwords.
For each virtual host that you would like to give access to your PHPMyAdmin installation, create a symbolic link from the document root to the phpMyAdmin installation location (
cd /var/www/example.com/public_html sudo ln -s /usr/share/phpmyadmin
This will create a symbolic link named
phpmyadminin your document root.
Secure your phpMyAdmin directory using an
.htaccess file that only allows specified IP addresses to access it. You can do this by creating an
.htaccess file in your
phpmyadmin directory. Substitute the proper paths and IP addresses for your particular configuration:
order allow,deny allow from 22.214.171.124
You can force phpMyAdmin to use SSL in the phpMyAdmin configuration file
/etc/phpmyadmin/config.inc.php by adding the following lines under the
Server(s) configuration section:
$cfg['ForceSSL'] = 'true';
Testing Your phpMyAdmin Installation
To test phpMyAdmin, open your favorite browser and navigate to
https://example.com/phpmyadmin. You will be prompted for a username and password. Use the username “root” and the password you specified when you installed MySQL. Alternatively, you can log in using any MySQL user and retain their permissions.
If you can successfully log in, phpMyAdmin has been installed properly.
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
- How to Install MySQL with phpMyAdmin on Ubuntu 14.04
- How to Install MySQL with phpMyAdmin on Debian 7
- How to Install and Configure phpMyAdmin on Debian 8
- Manage MySQL with phpMyAdmin on Ubuntu 10.10 (Maverick) - Deprecated
- Manage MySQL with phpMyAdmin on Ubuntu 9.10 (Karmic) - Deprecated
This guide is published under a CC BY-ND 4.0 license.