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.
Enter a password for phpmyadmin to register with the database server. If left blank, a random password will be generated.
Re-enter the password to confirm:
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.
To fix this issue, click OK and abort the phpMyAdmin installation.
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
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';
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
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.
Congrats! This is how the phpMyAdmin dashboard looks like.
From here, you can create, delete, rename, and manage the databases easily.
Source : https://www.ostechnix.com/install-phpmyadmin-with-lamp-stack-on-ubuntu-16-04/