How to Install phpMyAdmin On Ubuntu Server For MySQL Administration

Make your MySQL database administration much easier with the help of GUI

MySQL is a powerful database program that helps to serve as the foundation of so many applications and services. In fact, many of the websites you visit (such as Facebook, GitHub, iStock, US Navy, YouTube, Spotify, and more) are powered by MySQL. For many database administrators, working from within the command-line interface is a no-brainer. But for some, having a user-friendly GUI can mean actually working with a level of efficiency the command prompt cannot offer. One of the best tools for this task is phpMyAdmin.

The phpMyAdmin tool is an incredibly easy to use interface that can be installed on off-the-shelf hardware with a single command. The only caveat to the installation is that it has changed from previous iterations and the MySQL permissions can be finicky.


Before we run the installation commands, it’s always smart to update and upgrade Ubuntu Server. Because the kernel might be upgraded, it’s best to run the update/upgrade process at a time when a reboot is possible. To update and upgrade Ubuntu Server, login and issue the following commands:

sudo apt-get update
sudo apt-get upgrade -y

When the above commands complete, reboot the server (if needed) and install the Apache and MySQL servers (if they aren’t already installed) with the command:

sudo apt-get install lamp-server^ -y

When that command completes, configure MySQL with the command:

sudo mysql_secure_installation

Upon issuing the above command, you will be prompted to create a password for the MySQL admin user, as well as:

  • Remove anonymous users y/n
  • Disallow root login remotely y/n
  • Remove test database and access to it y/n
  • Reload privilege tables now y/n

Answer yes to all of the above questions.

Next, install phpMyAdmin with the command:

sudo apt-get install phpmyadmin php-mbstring php-gettext -y
Screenshot of selecting the correct web server for phpMyAdmin

During the installation, you’ll be asked to select which web server will be used to run phpMyAdmin. Make sure to select apache2 from the options. To do this, follow these steps:

  1. Tap the spacebar on your keyboard to select apache2.

  2. Press the Tab key on your keyboard until Ok is selected and use the Enter key to continue on.

  3. Next, you will be prompted to Configure the database for phpmyadmin. Yes should already be selected, so use Enter on your keyboard to continue.

    Screenshot of the first phpMyAdmin configuration window.
  4. Next, you’ll be prompted to create a password for the phpmyadmin user. Make this a unique and strong password. Type this new password, tab down to Ok, use the Enter key on your keyboard to continue, and then (when prompted) verify the newly created password.

    Screenshot of creating a password for the phpMyAdmin installation.
  5. This completes the first stage of the installation.

Configuring User Privileges

Screenshot of the MySQL prompt.

In prior iterations, you could now point your browser to http://SERVER_IP/phpmyadmin (Where SERVER_IP is the IP address of the hosting server) and log in with the MySQL admin user credentials. That is no longer the case. Instead, you must give the phpmyadmin user the necessary privileges to manage the databases. To do this, go back to the terminal window on your server and open the MySQL database prompt with the following command:

sudo mysql

At the MySQL prompt, issue the following commands:

GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' IDENTIFIED BY ‘password’;

Where password is the password you created for the phpmyadmin user during installation.

Creating a New User

If you’d rather create a new user (one that will also be able to manage databases from within phpMyAdmin), issue the following commands:

sudo mysql
CREATE USER username IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO ‘username’@'localhost' IDENTIFIED BY ‘password’;

Where username is the username to be created and password is a unique and strong password for the user.

Logging Into phpMyAdmin

Screenshot of the phpMyAdmin login screen.

Now it’s time to point your browser to http://SERVER_IP/phpmyadmin (Where SERVER_IP is the IP address of your server). You will be prompted for a username and password. Here you can either use phpmyadmin as the user and the password you created for the phpmyadmin user (during installation) or the new user/password you created from the MySQL prompt.

Screenshot of the phpMyAdmin Databases window.

If you select the Databases tab, you should see that the user you logged in with has all the necessary permissions to start working with the MySQL databases, via the phpMyAdmin interface. Create and manage databases, tables, and data from within this user-friendly web-based MySQL GUI.

Was this page helpful?