Recommended VPS Complete list of best VPS hosting providers.

How to Setup phpMyAdmin on Ubuntu 16.04 LAMP Server (Apache2 + PHP7)

Bringing more awesomeness within its new version release, the Ubuntu 16.04 has been also available as ready-to-use template on many of Cloud Server providers including Atlantic.net and Digital Ocean. This new Ubuntu server build has included PHP7, MariaDB, and phpMyAdmin in its repository. It means users can simply install those apps by simply using apt-get install command. However, some users may still be faced with common problem because the installation procedure has been done improperly.

In this article, you’ll see a proper method on how to install / setup world’s most popular MySQL management software, phpMyAdmin, on Ubuntu 16.04 server running Apache2, MariaDB and PHP7.

Prerequisites

  1. A SSH client like Bitvise or Putty and basic knowledge about how to use it.
  2. Basic knowledge about common Unix command to SSH to your server.
  3. A server or VPS with at least 256MB of RAM (OpenVZ) but 512MB is recommended if you are using KVM or Xen.
  4. About 30 minutes of your time.
  5. a cup of coffee or tea.

Confused on choosing which VPS provider to setup an Apache based hosting server? Read my recommended VPS providers or this list of top low end cloud server providers. Quick recommendation: Digital Ocean, Atlantic.net or Ramnode.

Prerequisites

  1. A SSH client like Bitvise or Putty and basic knowledge about how to use it.
  2. Basic knowledge about common Unix command to SSH to your server.
  3. A server or VPS with at least 256MB of RAM (OpenVZ) but 512MB is recommended if you are using KVM or Xen.
  4. About 30 minutes of your time.
  5. a cup of coffee or tea.

Confused on choosing which VPS provider to setup an Apache based hosting server? Read my recommended VPS providers or this list of top low end cloud server providers. Quick recommendation: Digital Ocean, Atlantic.net or Ramnode.

In this guide I am using a 512MB RAM Cloud VPS from Atlantic running Ubuntu 16.04 x64.

Do not forget to always replace domain.tld with your own domain name and replace x.x.x.x with your server IP address.

Install phpMyAdmin

Step 1 – First thing and the most important part, you have to install complete LAMP stack on Ubuntu 16.04 including PHP7, MariaDB server and Apache2 webserver.

Step 2 – Now install phpMyAdmin using this command :

apt-get install phpmyadmin

phpMyAdmin Install Command

Step 3 – The installer will then ask you an option to use dbconfig-common to configure phpMyAdmin. Select Yes.

Configure Phpmyadmin

Step 4 – Now you have to define a password for phpmyadmin database.

Define phpmyadmin database password

You’ll then be asked once more to confirm the password.

phpmyadmin db password confirmation

Step 5 – Once finished, the phpMyAdmin should now been installed. However, in rare cases you may also end up with error message saying :

ERROR 1045 (28000) : Access denied for user ‘root’@’localhost’ (using password : NO). Your options are … (etc)

If that what happens, follow these additional steps :

First, Simply choose Abort.

Then login to mysql as root using the password you’ve defined when you install MariaDB.

mysql -u root -p

Next, issue following command :

CREATE DATABASE phpmyadmin;
GRANT ALL ON phpmyadmin.* TO phpmyadmin@localhost IDENTIFIED BY 'changethispassword';
\q

Do not forget to replace changethispassword with your own password.

create database for phpmyadmin

Next, edit database configuration :

nano /etc/phpmyadmin/config-db.php

then edit the dbpass parameter with the password you’ve just defined.

<?php
##
## database access settings in php format
## automatically generated from /etc/dbconfig-common/phpmyadmin.conf
## by /usr/sbin/dbconfig-generate-include
##
## by default this file is managed via ucf, so you shouldn't have to
## worry about manual changes being silently discarded.  *however*,
## you'll probably also want to edit the configuration file mentioned
## above too.
##
$dbuser='phpmyadmin';
$dbpass='changethispassword';
$basepath='';
$dbname='phpmyadmin';
$dbserver='localhost';
$dbport='';
$dbtype='mysql';

replace changethispassword with your own.

phpmyadmin db config setup

Again, hit Control+O to save and Control+X to exit Nano editor.

Step 6 – Install the required PHP7 modules (without this, your phpMyAdmin won’t work).

phpmyadmin error mbstring needed

hence, issue this command :

apt-get install php-mbstring php7.0-mbstring php-gettext

install required php7 modules phpmyadmin

Step 7 – Adjust Apache2 config file to make phpMyAdmin accessible :

nano /etc/apache2/apache2.conf

Step 8 – Scroll down the configuration page till the bottom and add this :

Include /etc/phpmyadmin/apache.conf

Save changes and exit Nano editor.

adjust apache config phpmyadmin

Step 9 – Restart Apache2 service :

service apache2 restart

Step 10 – Finally, open up your favorite web browser again and try accessing phpMyAdmin for the first time via this url :

http://x.x.x.x/phpmyadmin

replace x.x.x.x with your server IP address.

login phpmyadmin ubuntu 1604

Use this credential for your first login:

  • Username : root
  • Password : MySQL password for root you have defined during installation (see section MariaDB Install at Step 2 – Step 3 here)

And you are in!

phpmyadmin interface ubuntu 1604

Once you have logged in, you can then manage your MySQL database using the graphical web based user interface. You can create new database, tables, database users, granting users access to specific database, and so on without having to login via Putty / Terminal again. That’s all and again, do not forget to follow me on twitter or subscribe using your email to get faster update on any new article.

3 Comments

Add a Comment

Your email address will not be published. Required fields are marked *

Get more stuff like this
in your inbox

Subscribe and get interesting stuff plus faster updates to your email.