Install PhpMyAdmin on Linux

How to install PhpMyAdmin on Linux, MySQL and MariaDB administrator with web interface. We will be using Ubuntu, but the process will be similar on other distributions.

In this article we are going to learn how to install the PhpMyAdmin software via the command line, so that it is available on a web server under Linux. We will configure PhpMyAdmin to allow access using our MySQL root password.

The process is simple but it has a couple of details that, if they don’t tell you, it will take you a while to find them. But be careful, we are going to limit ourselves to installing it and putting it into operation oriented to a PHP development server that we have on Linux, so this process could have some additional step, oriented to security, if you want to install it on a server in production open to the public.

We will work on Ubuntu and Apache. The process to install it on another Linux distribution will be the same, except if you have another package manager, like Yum for CentOS / Fedora. But except for this detail, the rest will be the same.

First step: Install MySQL

Obviously, it would not be very normal to install PhpMyAdmin if you do not have a MySQL database on your system, or the MariaDB database, which you should know is compatible with MySQL. If you already have MySQL / MariaDB installed on your system, you could skip this step, you just need to remember your root password.

The command to install MySQL on Ubuntu or Debian is this:

sudo apt-get install mysql-server mysql-client

The installation process will ask you to enter a password for the MySQL root user, which you can indicate what you want. Ubuntu 18.04 users should be aware that during MySQL installation it no longer asks for the password to be set for the root user. The empty key will simply be installed, that is, the root user will allow access without a key.

Remember to keep the MySQL server running with:

sudo service mysql start

Install PhpMyAdmin

Again we will use the Ubuntu package manager to install PhpMyAdmin. We will do it with the following command.

sudo apt-get install phpmyadmin php-mbstring php-gettext

Note that, in addition to PhpMyAdmin itself, we are installing a couple of PHP extensions that are required by PhpMyAdmin. It is common for these extensions to be already configured in your PHP installation, but it never hurts to indicate them in the installation, just in case.

When PhpMyAdmin is being installed, it asks us for some extra configuration information, in a kind of command line wizard.

First, it asks us for the name of the web server on which you want to configure PhpMyAdmin. We inform you that it is “Apache 2”. To do this we have to place ourselves on the “Apache2” option and press the space bar so that a “*” appears. Then with the tabulator we go to “Ok” and press Enter.

Then it offers us the possibility of carrying out the initial configuration of the database for us with dbconfig-common. Something that will generally be desirable. To do this, we simply place ourselves on the “Yes” option with the tabulator and press Enter.

Finally, it asks us to enter the MySQL root password. You set that key when you installed MySQL, or it is the empty key if you installed MySQL on Ubuntu 18.04.

Restart Apache

Don’t forget to restart Apache after you’ve done the PhpMyAdmin installation, or any changes to the web server configuration or PHP modules.

The most typical command to restart apache is this:

service apache2 restart Note: Depending on your system, including Linux distribution, you might require other commands to restart Apache. We recommend reading the article on the . You will also find commands to restart MySQL, if necessary.

Additional steps for installing PhpMyAdmin on Linux

Now we are going to describe another series of steps to configure aspects necessary for the correct functioning of PhpMyAdmin. Some of them you may not need, but it is ideal that you read these steps to solve possible problems or specific needs of your system.

Activate the mbstring module

In case the php-mbstring extension is not installed, you may have to run the command:

sudo phpenmod mbstring

In case you don’t know, the phpenmod command is used to activate a specific PHP module.

Set root access with password

In PhpMyAdmin a connection model is required which is not active for the root user by default. So you may have to do an extra step.

First you connect to the MySQL client. You can do it with commands like these:

mysql -u root

Or if your root user has a password set, you’ll have to type:

mysql -u root -p

Once inside we are going to list the users and their authentication model. You do it with this SQL statement:

SELECT user,authentication_string,plugin,host FROM mysql.user;

You will see an output similar to the one seen in the following image. If you notice that the root user only has “auth_socket” in the “plugin” column, it means that it will not allow you access from PhpMyAdmin, because to authenticate from PHP you need to have the “mysql_native_password” option.

To change it we can do the following SQL statement.

ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘1234’;

Note that this statement does two things:

  1. Add mysql_native_password as allowed authentication method
  2. Set the password to “1234” for the root user. Of course, here you can place the key that you like the most. Just make sure you remember it for later access.

Now if you re-run the SQL statement from before “SELECT user,authentication_string,plugin,host FROM mysql.user;” You will see that it shows you another user configuration table.

Extra settings for PhpMyAdmin

For any other extra details that you have to touch to configure PhpMyAdmin, you have to do it on the configuration file, which is in the path:

etc/phpmyadmin/config.inc.php

It’s a PHP file where you have several configuration value declarations. A common thing you might need is to allow login with empty MySQL root password “” (Error Login without a password is forbidden by configuration). To do this you have to find and uncomment all occurrences of the “AllowNoPassword” statement, or simply set the value to “true”.

$cfg = TRUE;

conclusion

That is all! now you will be able to access the path where PhpMyAdmin has been installed, which is http://localhost/phpmyadmin

There it will ask you for the access credentials of the user you want to use to connect to MySQL. Just keep in mind the details explained above so you don’t get errors. The most common problems we have already described above, so review the article if any of them occur to you when accessing PhpMyAdmin.

See also  Introduction to databases
Loading Facebook Comments ...
Loading Disqus Comments ...