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

Step 2 — Install phpmyadmin:

For installation phpmyadmin in Ubuntu 18.04 you need to do:

sudo apt install phpmyadmin php-gettext

You will see a window like:

Select apache2 in our case.

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

The restart Apache2

sudo systemctl restart apache2

Optional: Remove phpmyadmin:

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:

Case 1:

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

The requested URL /phpmyadmin was not found on this server

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:

Case 2:

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’

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:

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:

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:

Case 3:

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

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:

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

Case 4:

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:

After:

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!

Posting daily about Python, Nuclear Physicist PhD