Install Phpmyadmin On Ubuntu

How to Install phpMyAdmin on Ubuntu

Written by: Jacob Nicholson

Jacob Nicholson

Jacob Nicholson has worked at all levels of both small and large web hosting companies. With a background in computer networking, he enjoys all things Internet, as well as trying out the latest and greatest technology. After several years of serving in a system administration role, he transitioned to become a customer advocate, focused on streamlining common web hosting woes with detailed online guides. He brings with him tons of experience and lots of passion for the wonderful world of web hosting — and he's eager to share his knowledge with HostingAdvice fans.

Edited by: Lillian Castro

Lillian Castro

Lillian brings more than 30 years of editing and journalism experience to our team. She has written and edited for major news organizations, including The Atlanta Journal-Constitution and the New York Times, and she previously served as an adjunct instructor at the University of Florida. Today, she edits HostingAdvice content for clarity, accuracy, and reader engagement.

See full bio »

The MySQL database system is the most popular, open-source, relational database. Many other projects, including WordPress, are backed by a MySQL database and rely on its extensive feature list and simple setup. For beginners, or those that are lazy, there is the phpMyAdmin tool to help us with the maintenance and interface of MySQL.

Accessed from your web browser, phpMyAdmin is a PHP-based frontend control panel that allows you to easily manage your MySQL databases and users, review SQL activity, import and export database backups, run searches, and more.

In this guide, we’ll cover the recommended method to install phpMyAdmin from the Ubuntu packages, and how to secure phpMyAdmin. We’ll also go over installing phpMyAdmin from source, although this is not recommended in a production environment.

Requirements for Installing phpMyAdmin on Ubuntu

Before installing phpMyAdmin, we need to meet some basic requirements:

Install phpMyAdmin from Ubuntu Packages

The default Ubuntu repositories stay up-to-date with the latest stable releases of phpMyAdmin, and this is the recommended installation process for a production environment.

Step 1: Update Package Index

First, we need to make sure our local server is pulling the latest updates.

sudo apt-get update

Step 2: Install phpMyAdmin Package

Now we can install the latest version of phpMyAdmin.

sudo apt-get install -y phpmyadmin

Step 3: Configure phpMyAdmin Package

After installing phpMyAdmin, you will be presented with the package configuration screen.

Press the SPACE bar to place an “*” beside “apache2.”

Press TAB to highlight “OK,” then hit ENTER.

Select “apache2” and hit OK.

The installation process will continue until you’re back at another package configuration screen.

Select “Yes” and then hit ENTER at the dbconfig-common screen:

Select “Yes” and hit ENTER.

You will be prompted for your database administrator’s password.

Type it in, hit TAB to highlight “OK,” and then press ENTER.

Enter your DB administrator’s password.

Next, enter a password for the phpMyAdmin application itself.

Enter the password you’d like to use to access the phpMyAdmin interface.

Confirm the phpMyAdmin application password.

Confirm your phpMyAdmin password.

After the installation process completes, it adds the phpMyAdin configuration file here:

/etc/apache2/conf-enabled/phpmyadmin.conf

Enable PHP mcrypt Module

Check if the PHP mcrypt module is already in use:

php -m | grep mcrypt

If you don’t get any results, install the PHP mcrypt module with:

sudo php5enmod mcrypt

Now when we check, you should see mcrypt enabled:

$ php -m | grep mcrypt  mcrypt

Restart Apache

Now we should restart the Apache web server for changes to take affect:

sudo service apache2 restart

Access phpMyAdmin for the First Time

Now you can log in to phpMyAdmin by going to your server followed by /phpmyadmin.

You can just use http://YOUR_SERVER_IP/phpmyadmin if you don’t have domains set up yet.

Log in with the root user and the password you set for the phpMyAdmin application.

Log in to phpMyAdmin as the root user.

Now you’ll see the phpMyAdmin dashboard.

You should now see the phpMyAdmin dashboard.

Secure and Lock Down phpMyAdmin Interface

Naturally, because phpMyAdmin is such a common application installed on many web servers, it is a popular target for unauthorized access attempts. We can easily secure our phpMyAdmin installation by using Apache’s built-in .htaccess authentication.

Step 1: Edit phpMyAdmin’s Apache Config

We want to edit the phpMyAdmin Apache config that was created earlier:

sudo vi /etc/apache2/conf-available/phpmyadmin.conf

Add AllowOverride “ALL” directive below the DirectoryIndex:

          Options FollowSymLinks          DirectoryIndex index.php          AllowOverride ALL          ...

Step 2: Restart Apache to Accept Config Changes

Restart Apache so our changes take affect:

sudo service apache2 restart

Step 3: Create an .htaccess File

Now that we’ve enabled overrides for our phpMyAdmin application from Apache, we need to actually create an override with an .htaccess file.

sudo vi /usr/share/phpmyadmin/.htaccess

Add this text:

AuthType Basic  AuthName "phpMyAdmin Users Only"  AuthUserFile /etc/phpmyadmin/.htpasswd  Require valid-user

Step 4: Create an .htpasswd File for Authentication

First we need the htpasswd utility. If you don’t already have this installed, use the following:

sudo apt-get install apache2-utils

Now we can create a secure user for our phpMyAdmin application with the command:

$ sudo htpasswd -c /etc/phpmyadmin/.htpasswd phpmyadmin  New password:  Re-type new password:  Adding password for user phpmyadmin

If for some reason you wanted to give others access to the phpMyAdmin login screen but didn’t want them using your .htaccess credentials, you can create additional secure users with:

sudo htpasswd /etc/phpmyadmin/.htpasswd anotheruser

Now if you try to access the phpMyAdmin login, you’ll get the .htaccess password prompt first.

You should now see the .htaccess password prompt we created

Install phpMyAdmin from Source

While it’s not recommended for production servers, because you have to manually ensure your install of phpMyAdmin is kept up-to-date, you can also install phpMyAdmin from source.

Step 1: Identify Apache’s DocumentRoot

We need to find Apache’s DocumentRoot so we know where to place our phpMyAdmin files:

$ grep DocumentRoot /etc/apache2/sites-available/000-default.conf          DocumentRoot /var/www/html

In this case, we’ll need to put the phpMyAdmin files in /var/www/html.

Step 2: Download Latest Version of phpMyAdmin

The stable version of phpMyAdmin at the time this article was written: phpMyAdmin 4.3.11.1 (released 3/4/2015).

Visit the phpMyAdmin download page to grab the latest version of phpMyAdmin.

I ended up with a phpMyAdmin-4.3.11.1-english.tar.gz file in my /var/www/html directory.

$ cd /var/www/html  $ ls  index.html phpMyAdmin-4.3.11.1-english.tar.gz

Step 3: Unpack phpMyAdmin Files

sudo tar xvzf phpMyAdmin-4.3.11.1-english.tar.gz

Now rename the phpMyAdmin-4.3.11.1-english directory:

sudo mv phpMyAdmin-4.3.11.1-english phpmyadmin

Remove the phpMyAdmin files:

sudo rm phpMyAdmin-4.3.11.1-english.tar.gz

Step 4: Secure /phpmyadmin Directory

We want to set up a specific user for our phpMyAdmin install.

$ sudo adduser phpmyadmin  Adding user `phpmyadmin' ...  Adding new group `phpmyadmin' (1001) ...  Adding new user `phpmyadmin' (1001) with group `phpmyadmin' ...  Creating home directory `/home/phpmyadmin' ...  Copying files from `/etc/skel' ...  Enter new UNIX password:  Retype new UNIX password:  passwd: password updated successfully  
sudo chown -R phpmyadmin.phpmyadmin /var/www/html/phpmyadmin

Step 5: Update phpMyAdmin config.inc With Install Wizard

To use the phpMyAdmin install wizard, we first need to set up the config.inc file.

cd /var/www/html/phpmyadmin  sudo mkdir config  sudo chmod o+rw config  sudo cp config.sample.inc.php config/config.inc.php  sudo chmod o+w config/config.inc.php

Step 6: Run phpMyAdmin Install Wizard

To begin the installation of phpMyAdmin, access the installation URL at:

http://example.com/phpmyadmin/setup/index.php

Under the “Servers” section, click on “New Server.”

Under the “Servers” section, click on “New Server.”

Under the “Authentication” tab, type in your MySQL root password in the “Password for Config Auth” box and then click “Apply.”

In the “Password for Config Auth” box, type in your MySQL root password.

Remove the phpMyAdmin /config directory for security.

sudo rm -rf /var/www/html/phpmyadmin/config

Final Thoughts on phpMyAdmin

Now that you’ve successfully installed phpMyAdmin on Ubuntu, you can start playing around with some of its more advanced features.

One thing we recommend taking a look at is the “Status” tab, which will display any current MySQL queries that are running on the server, as well as server uptime and the number of connections to the MySQL server.

Check out the official phpMyadmin documentation for more using phpMyAdmin.

Advertiser Disclosure

HostingAdvice.com is a free online resource that offers valuable content and comparison services to users. To keep this resource 100% free, we receive compensation from many of the offers listed on the site. Along with key review factors, this compensation may impact how and where products appear across the site (including, for example, the order in which they appear). HostingAdvice.com does not include the entire universe of available offers. Editorial opinions expressed on the site are strictly our own and are not provided, endorsed, or approved by advertisers.

Our Editorial Review Policy

Our site is committed to publishing independent, accurate content guided by strict editorial guidelines. Before articles and reviews are published on our site, they undergo a thorough review process performed by a team of independent editors and subject-matter experts to ensure the content’s accuracy, timeliness, and impartiality. Our editorial team is separate and independent of our site’s advertisers, and the opinions they express on our site are their own. To read more about our team members and their editorial backgrounds, please visit our site’s About page.

ABOUT THE AUTHOR

Jacob Nicholson

Jacob Nicholson has worked at all levels of both small and large web hosting companies. With a background in computer networking, he enjoys all things Internet, as well as trying out the latest and greatest technology. After several years of serving in a system administration role, he transitioned to become a customer advocate, focused on streamlining common web hosting woes with detailed online guides. He brings with him tons of experience and lots of passion for the wonderful world of web hosting — and he's eager to share his knowledge with HostingAdvice fans.

« BACK TO: HOW-TO
Follow the Experts
We Know Hosting

$

4

8

,

2

8

3

spent annually on web hosting!

Hosting How-To Guides
What Is Cloud Hosting?

Joe Warnimont, 4/23/24

What Is a Domain Name?

Lynn Cadet, 4/22/24

30 Global Internet Usage Statistics

Surajdeep Singh, 4/18/24