Install phpMyAdmin with Nginx on Ubuntu 18.04 - Step by Step Process ?

phpMyAdmin is a free and web interface based database management tool for managing MySQL and MariaDB. You can manage MySQL databases, user accounts and privileges, import and export data and much more using phpmyadmin interface. 

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related phpMyAdmin queries on Ubuntu Linux System.

In this context, we shall look into how to install phpMyAdmin with Nginx on Ubuntu 18.04 system.

How to Install phpMyAdmin with Nginx on Ubuntu ?

Before proceeding with this Installation procedure, ensure that the following requirements are met:

You must logged in on Ubuntu server as a user account with sudo privileges.

Ensure that LEMP (Linux, Nginx, MySQL and PHP) stack is installed on your Ubuntu machine.

We strongly recommend to access your phpMyAdmin installation over HTTPS connections. So it will prevent from unnecessary attacks to phpmyadmin. If your domain is not secure with an SSL/TLS certificate, you can follow this guide to Secure Nginx with Let's Encrypt on Ubuntu.

i. To begin, to start installation you need to update Ubuntu package index and upgrade system by using the following command:

$ sudo apt update
$ sudo apt upgrade

ii. Now, install the phpMyAdmin package from the default Ubuntu repositories with the below command:

$ sudo apt install phpmyadmin

It will prompt you for few configuration options. At first, it will ask to choose web server. There is no option for Nginx so press Tab and click OK button.

iii. Next, you will be ask to use dbconfig-common to configure the database for phpMyAdmin.

iv. Select Yes and hit Enter key to continue.

v. Now enter password for phpMyAdmin to register with the database, select OK and press Enter.

Again, you will be prompted to confirm the password by entering same password and hit on OK button.

Now, phpMyAdmin will be installed on your Ubuntu server.

vi. After that we will create a symbolic link to access phpMyAdmin interface from installation files. You can link it to the document root directory by executing:

$ sudo ln -s /usr/share/phpmyadmin /var/www/html

How to Create MySQL User and Set Privileges ?

In Ubuntu systems, the root MySQL user is using the auth_socket plugin by default to authenticate. It means that you can't authenticate as a root by providing a password. This will increase some greater security and usability in many cases, but it can also complicate when you need to allow an external program like phpMyAdmin.

In order to log in to phpMyAdmin as your root MySQL user, you will need to switch its authentication method from auth_socket to mysql_native_password. It will not be good to change authentication method for the MySQL root user. 

Since phpMyAdmin requires users to authenticate with a password, so instead of changing authentication method we will create a new administrative MySQL account in order to access the interface. This user will have the same privileges as the root user and will be set to use the mysql_native_password authentication method.

Now, we will use that user to login to phpMyAdmin and do further administrative tasks on our MySQL or MariaDB server.

You can login by below command:

$ sudo mysql

Next, create a new administrative user with strong password and grant appropriate permissions by typing:

mysql> CREATE USER 'newadmin'@'localhost' IDENTIFIED BY 'STRONG-PASSWORD';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'newadmin'@'localhost' WITH GRANT OPTION;

How to Access phpMyAdmin ?

To access the phpMyAdmin interface open web browser and type your server's public IP address or domain name followed by /phpmyadmin:


Enter the administrative account username and password which you created in the previous step and hit on Go button.

After successful log in, you'll see the phpMyAdmin user interface.

[Need assistance in fixing Server Databases and phpMyadmin issues? We can help you. ]


This article covers how to Install phpMyAdmin with Nginx on Ubuntu 18.04 system. When developing a website or web application, many users need the functionality of a database system like MySQL. However, interacting with the system solely from the MySQL command-line client requires familiarity with Structured Query Language — more commonly referred to as SQL — which can present a major hurdle for some users. phpMyAdmin was created to allow users to interact with MySQL through an intuitive web interface, running alongside a PHP development environment. 

How to Secure phpMyAdmin with Let's Encrypt SSL ?

Before starting, you will need to install the Certbot client to download and install Let's Encrypt SSL.

1. First, add the Certbot repository with the following command:

$ add-apt-repository ppa:ahasenack/certbot-tlssni01-1875471

2. Next, update the repository and install the Certbot client using the following command:

$ apt-get update -y
$ apt-get install certbot python3-certbot-nginx -y

3. Once the Certbot has been installed, run the following command to download and install the Let's Encrypt SSL for your domain:

$ certbot --nginx -d phpmyadmin.domain.com