How to setup Phpmyadmin on Ubuntu 16.04 LAMP Server

The new version of Ubuntu server has included PHP7, MariaDB, and phpMyAdmin in its repository. That means users can easily install those apps by simply using apt-get install command. 

In this article, I will guide a proper way to install / setup MySQL management software, phpMyAdmin, on Ubuntu 16.04 server running Apache2, MariaDB and PHP7.

PREREQUISITES

  1. A SSH client like Putty and basic knowledge about to use it.
  2. Basic knowledge about common Linux commands
  3. A server or VPS
  4. About 30 minutes of your time with a cup of coffee or tea.

INSTALL PHPMYADMIN

Step 1 – I am assuming here that you have already installed 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

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

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

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

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

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

If it 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

Replace changethispassword with your own password.

Next, edit database configuration :

nano /etc/phpmyadmin/config-db.php

Then edit the dbpass parameter with the password you’ve just chosen.

<?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';

save the file and exit the editor.

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

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

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 editor.

Step 9 – Restart Apache2 service :

service apache2 restart

Step 10 – Now, open up your browser and try to access phpMyAdmin via this url :

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

Replace x.x.x.x with your server IP address.

That’s all  you have to do, You also like to know about performance tuning script for MySQL, please check that and also give your opinion below if you experience any issues or to discuss your ideas and experiences.

Leave a Reply

Register to Get FREE Offers

Why Pay for Software when you can GET it for FREE

JOIN US TONIGHT!