How to Install phpMyAdmin on Ubuntu 18.04

Install phpMyAdmin on Ubuntu

phpMyAdmin is one of the most popular and widely-used web-based database management tools on the market. It is a free and open-source PHP application that allows users to manage single or multiple SQL database servers, both locally or on a remote server using a web browser with easy to use graphical user interface. It can be used to handle the administration of MySQL as well as MariaDB databases. You can create, modify, and delete databases or tables, execute SQL queries, manage your MySQL user accounts and privileges, and much more, all from your web browser. Today, we are going to show you how to install phpMyAdmin on Ubuntu 18.04.

We have an updated version of this tutorial – How to Install phpMyAdmin on Ubuntu 20.04

Requirements:

  • For the purposes of this tutorial, we will be using an Ubuntu 18.04 VPS.
  • You will also need a working LAMP or LEMP (Linux, Apache/Nginx, MySQL, PHP) stack. Our Ubuntu 18.04 VPS already comes pre-installed with a fully-configured LAMP stack.
  • Full SSH root access or a user with sudo privileges is also required.

Step 1: Connect to Your Server

Before we begin,  you need to connect to your server via SSH as the root user or any other user with sudo privileges.

To connect to your server as the root user, use the following command:

ssh root@IP_ADDRESS -p PORT_NUMBER

Make sure to replace IP_ADDRESS and PORT_NUMBER with your actual server IP address and SSH port number.

Once logged in, make sure that your server is up-to-date by running the following commands:

sudo apt update
sudo apt upgrade

Step 2: Install phpMyAdmin

phpMyAdmin is already available in the default Ubuntu package repositories.

To install phpMyAdmin, along will all of the required dependencies, run the following command:

sudo apt install phpmyadmin

During the installation, you will be asked a couple of questions.

Choose apache2 as your web server:

Choose <Yes> to configure a database for phpMyAdmin with dbconfig-common:

Enter and confirm a MySQL application password for phpMyAdmin:

With this last step, the phpMyAdmin installation has been completed.

To access your phpMyAdmin, first restart your apache2 web server with:

systemctl restart apache2

and type http://yourIPaddress/phpmyadmin in your browser to access the login page:

Step 3: phpMyAdmin Login

To manage your databases using phpMyAdmin, you will need to either log in as the MySQL root user or as another MySQL user account with administrative privileges. We will show you how to log in using both of these methods.

Log in as root

By default, the root user is set to use the auth_socket plugin in order to authenticate to your MySQL database server. If you want to be able to authenticate as the root user in your phpMyAdmin, you will have to change the authentication method from auth_socket to mysql_native_password.

To do this, connect to your server via SSH, and then log in to your MySQL database server by typing the following command:

sudo mysql

This will take you to the MySQL shell as the MySQL root user. To check the authentication method of all of your users, you can execute the following:

SELECT user,plugin FROM mysql.user;

You will get the following output on your screen:

+------------------+-----------------------+
| user             | plugin                |
+------------------+-----------------------+
| root             | auth_socket           |
| mysql.session    | mysql_native_password |
| mysql.sys        | mysql_native_password |
| debian-sys-maint | mysql_native_password |
| phpmyadmin       | mysql_native_password |
+------------------+-----------------------+

In order to change the authentication plugin from auth_socket to mysql_native_password for your root user, you will need to run the following:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'STRONG_PASSWORD';

Make sure that you replace the STRONG_PASSWORD part with an actual strong password that you would like to use for your MySQL root user.

After this is done, you will need to flush all privileges in order for the changes to take effect:

FLUSH PRIVILEGES;

You can then run the same command again to check if the authentication method has been successfully updated:

SELECT user,plugin FROM mysql.user;

Output:

+------------------+-----------------------+
| user             | plugin                |
+------------------+-----------------------+
| root             | mysql_native_password |
| mysql.session    | mysql_native_password |
| mysql.sys        | mysql_native_password |
| debian-sys-maint | mysql_native_password |
| phpmyadmin       | mysql_native_password |
+------------------+-----------------------+

To disconnect from the MySQL database server, you can type:

exit;

You can now use your MySQL user to log in to your phpMyAdmin and manage your databases.

Create a new admin user

Another option is to create a new MySQL user with administrative privileges. We will show you how to create a new user called “admin” which you can use to log in to your phpMyAdmin.

Need a fast and easy fix?
✔ Unlimited Managed Support
✔ Supports Your Software
✔ 2 CPU Cores
✔ 2 GB RAM
✔ 50 GB PCIe4 NVMe Disk
✔ 1854 GeekBench Score
✔ Unmetered Data Transfer
NVME 2 VPS

Now just $43 .99
/mo

GET YOUR VPS

To create this new user, once again log in to your MySQL database server with:

sudo mysql

And run the following command:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD';

Again, make sure you set a strong password for your user. Next, set the appropriate privileges by running:

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

To exit the MySQL database server, type:

exit;

Step 4: Conclusion

Congratulations! If you have made it to this step, you have successfully installed phpMyAdmin on your Ubuntu 18.04 VPS. You will be able to log in at http://yourIPaddress/phpmyadmin as the root user or as another administration user, depending on which of the two methods you decided to set up during the tutorial. Upon successful authentication, you will be taken to the main phpMyAdmin management page, as shown in the screenshot below, from which you can start working with your databases.


Of course, if you are one of our Ubuntu Hosting customers, you don’t have to install phpMyAdmin on your Ubuntu 18.04 VPS – simply ask our admins, sit back, and relax. Our admins will install phpMyAdmin on Ubuntu 18.04 for you immediately. You can also check this guide: How to Install phpMyAdmin on Ubuntu 20.04 for updates.

PS. If you liked this post about how to install phpMyAdmin on Ubuntu 18.04 VPS, please share it with your friends on the social networks using the buttons below, or simply leave a comment in the comments section. Thanks.

Leave a Comment