Home WebserverApache Install phpMyAdmin with LAMP stack on Ubuntu 16.04

Install phpMyAdmin with LAMP stack on Ubuntu 16.04

By sk
Published: Last Updated on 1.7K views

phpMyAdmin is a free, open source web-based database management tool written using PHP programming language. It allows the database administrators to manage single or multiple database servers either from a local or remote system using a web browser. Using phpMyAdmin, we can create, delete, rename, edit databases, tables, fields, and also we can directly execute any SQL commands. Currently, It supports MySQL, MariaDB, and Drizzle database servers. In this tutorial, we will see how to install phpMyAdmin with LAMP stack in Ubuntu 16.04 lTS server.

Install phpMyAdmin with LAMP stack in Ubuntu 16.04 LTS

First, Setup LAMP stack in your Ubuntu 16.04 LTS server as described in the following link.

phpMyAdmin is available in the default repositories of Ubuntu operating system. Once LAMP stack is installed and ready, install phpMyAdmin as shown below:

sudo apt-get install phpmyadmin
Install phpmyadmin

Install phpmyadmin

During installing, you'll be asked to choose the web server that should be automatically configured to run phpMyAdmin. In our case, it is Apache webserver.

Choose apache2 and click OK.

sk@ubuntuserver: ~_002

Select Yes and hit ENTER to configure database for phpmyadmin with dbconfig-common.

sk@ubuntuserver: ~_003

Enter a password for phpmyadmin to register with the database server. If left blank, a random password will be generated.

sk@ubuntuserver: ~_004

Re-enter the password to confirm:

sk@ubuntuserver: ~_005

Oops! You might be encountered with the following error message:

An error occurred while installing the database: 

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using 
password: NO) . Your options are: 
* abort - Causes the operation to fail; you will need to downgrade, 
   reinstall, reconfigure this package, or otherwise manually intervene 
   to continue using it. This will usually also impact your ability to 
   install other packages until the installation failure is resolved. 
* retry - Prompts once more with all the configuration questions 
   (including ones you may have missed due to the debconf priority 
   setting) and makes another attempt at performing the operation. 
* retry (skip questions) - Immediately attempts the operation again, 
   skipping all questions. This is normally useful only if you have 
   solved the underlying problem since the time the error occurred.

sk@ubuntuserver: ~_006

To fix this issue, click OK and abort the phpMyAdmin installation.

sk@ubuntuserver: ~_007

Log in to MariaDB or MySQL prompt with root user using command:

mysql -u root -p

Create a new database and database user for phpMyAdmin and grant full permission to the phpmyadmin user.

For the purpose of this tutorial, I am going to create a database called "phpmyadmindb", and database user "phpmyadminuser" with password "ubuntu". Please use a strong password which is very hard to guess in the production environment.

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 52
Server version: 10.0.25-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> CREATE DATABASE phpmyadmindb;
Query OK, 1 row affected (0.01 sec)

MariaDB [(none)]> GRANT ALL ON phpmyadmindb.* TO phpmyadminuser@localhost IDENTIFIED BY 'ubuntu';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> \q
Bye

sk@ubuntuserver: ~_009

Then, edit phpmyadmin/config-db.php file:

sudo nano /etc/phpmyadmin/config-db.php

Replace the database name, database user and its password with the values that you have created earlier.

[...]

$dbuser='phpmyadminuser';
$dbpass='ubuntu';
$basepath='';
$dbname='phpmyadmindb';
$dbserver='localhost';
$dbport='';
$dbtype='mysql';

sk@ubuntuserver: ~_010

Save and close the file.

Next, you must install the following php modules. Otherwise, you will get an error message that says:

The mbstring extension is missing. Please check your PHP configuration.

To install php modules, run:

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

Then, edit Apache webserver config file:

sudo nano /etc/apache2/apache2.conf

Add the following line at the end:

Include /etc/phpmyadmin/apache.conf

sk@ubuntuserver: ~_011

Save and close the file. Restart apache service to take effect the changes.

sudo systemctl restart apache2

Access phpMyAdmin dashboard

Open up the web browser and navigate to http://IP-Address/phpmyadmin.

You should see the following screen. Enter the MariaDB/MySQL 'root' user name and its password.

phpMyAdmin - Chromium_012

Congrats! This is how the phpMyAdmin dashboard looks like.

192.168.1.105 - localhost | phpMyAdmin 4.5.4.1deb2ubuntu2 - Chromium_013

From here, you can create, delete, rename, and manage the databases easily.

You might want to download our free guides related to database, and PHP.

Hope this helps. If you find this guide useful, share it on your social networks and support OSTechNix.

For more details about phpMyAdmin, refer:

Cheers!

Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You May Also Like

7 comments

Think Strategy August 20, 2016 - 12:14 pm

To get the latest updates for PHPmyadmin

#PHPMyAdmin (16.04)
sudo apt-add-repository -y ppa:nijel/phpmyadmin

Reply
Aryan July 6, 2018 - 10:22 am

Thank you to give better installation & confirmation process.. (for phpmyadmin)

Reply
Aryan July 6, 2018 - 10:25 am

Or give better Configuration process of phpmyadmin..

Reply
sk July 6, 2018 - 11:08 am

You’re welcome, mate!

Reply
Biswajit Biswas May 29, 2018 - 4:31 pm

Thank You sir. It Worked for me. 🙂

Reply
Danish Sethi June 16, 2018 - 2:42 pm

Great it worked !

Reply
Raj October 6, 2018 - 12:24 am

Here at this step some user may need to ensure mysql password policy
following commands may be helpful–(only if password not accepted)

SHOW VARIABLES LIKE ‘validate_password%’;
SET GLOBAL validate_password_length = 6;
SET GLOBAL validate_password_number_count = 0;

Your password does not satisfy the current policy requirements—stack overflow(search)

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More