Install phpmyadmin on Ubuntu 18.04 with PHP 7.2 and LAMP stack

Step 1 — For installing LAMP stack read first this article:

Install Apache, MySQL, PHP 7.2 (LAMP) stack on Ubuntu 18.04

For installation phpmyadmin in Ubuntu 18.04 you need to do:

sudo apt install phpmyadmin php-gettext

You will see a window like:

Image for post
Image for post

Select apache2 in our case.

Image for post
Image for post

And select yes. and type a strong password and save it.

Image for post
Image for post

The restart Apache2

sudo systemctl restart apache2

This part is just for the case you encounter a problem during installation and want to remove phpmyadmin and install it again!

If you need to fully remove phpmyadmin in Ubuntu 18.04 you can do this:

sudo apt-get purge phpmyadmin

Note: The “purge” instead of “remove” instructs it to remove its configuration files too, including the configuration it added to Apache’s configuration directories. Note that if it set up its own MySQL database that database may not be removed, but you can do that manually.

Issues:

After you restart Apache2 you may not able to see the phpmyadmin login page!

Image for post
Image for post

To fix this issue you should do :

sudo -H gedit /etc/apache2/apache2.conf

Then add the following line to the end of the apache2.con file:

Include /etc/phpmyadmin/apache.conf

and then restart the Apache2

sudo systemctl restart apache2

You will see phpmyadmin login page as:

Image for post
Image for post

When you try to login with root user you can not enter phpmyadmin as root in (MySQL 5.7.26 ubuntu 18). The error is:

Mysqli_real_connect(): Access denied for user ‘root’@‘localhost’

Image for post
Image for post

This issue arises from the fact that the Plugin for root user is auth_socket.

To see this status enter mysql by : sudo mysql -u root -p

Then do this:

mysql>  SELECT User, Host, plugin FROM mysql.user;

You will see:

Image for post
Image for post

To fix this issue do this:

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YOUR_ROOT_PASSWORD';

Pay attention to ‘YOUR_ROOT_PASSWORD’ which must be your root password

The status must be finally the same as:

Image for post
Image for post

And again try to login phpmyadmin via root user and your password

http://example.com/phpmyadmin
or
http://127.0.0.1/phpmyadmin

You will see:

Image for post
Image for post

When you are in a database and click on the Export you will see a problem as :

Image for post
Image for post

The warning in Ubuntu 18.04 and PHP 7.2 is:

Warning in ./libraries/plugin_interface.lib.php#551count(): Parameter must be an array or an object that implements Countable

To fix this bug you should edit the file:

sudo nano /usr/share/phpmyadmin/libraries/plugin_interface.lib.php

and Ctrl+w to find this line

if ($options != null && count($options) > 0) {

and change it to

if ($options != null && count((array)$options) > 0) {

After change it seems like:

Image for post
Image for post

In fact we force the parameter to be an array!

Then Ctrl+x to exit and press y and confirm.

Then restart Apache2

sudo systemctl restart apache2

You my have another warning like:

Warning in ./libraries/sql.lib.php#601
count(): Parameter must be an array or an object that implements Countable

to fix it do this:

sudo nano /usr/share/phpmyadmin/libraries/sql.lib.php

and edit the file in a way that just move the ) to the above line in the picture:

Before:

Image for post
Image for post

After:

Image for post
Image for post

Thank you for reading! If you enjoyed this article:

Clap it ! Share it! Follow Me in Medium!

Also I’d like to hear your opinion on this article. If you have any doubt, question or suggestion please leave a comment below.

Have a very wonderful day!

Written by

Web geek, Self-taught full-stack web developer, Learning Python, Laravel, Vuejs, UX/UI design, Nuclear Physicist PhD

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store