How to install phpMyAdmin on Ubuntu 20.04?

Overview

Many customers need the functionalities that a DBMS like MySQL has to offer as they might not feel safe using the server simply through the MySQL client.

Users may communicate with MySQL using a website interface, thanks to phpMyAdmin. We'll go through how to set up phpMyAdmin on Ubuntu Linux 20.04 server, secure it, and then utilize it to safely manage your databases.

Prerequisites

There are certain prerequisites that need to be met before you begin.

Get Started

Step 1: Configuring phpMyAdmin

phpMyAdmin may be installed from the standard Ubuntu repositories using APT.

a. If you are a non-root user, use sudo command to upgrade the package index on your server:

$ sudo apt update

b. Run the below command to install these packages onto your system. First, we have to install php (if not already installed) using the following command:

$ sudo apt install php libapache2-mod-php php-mysql

c. Use the following command to download package and start phpMyAdmin installation.

$ sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl

Important: If you have enabled Validate Password plugin for MySQL, you will encounter this error. In order to resolve this, you need to disable password for mySQL and try again.

  1. Choose abort and do the following process after exit.

  2. Now open MySQL in your terminal.

$ sudo mysql

Or if you have set a password on MySQL then, use the following command:

$ sudo mysql -u root -p
  1. Use this command to uninstall the password component to prevent it from being started.

mysql> UNINSTALL COMPONENT "file://component_validate_password";
  1. Now exit your mysql client.

mysql> exit
  1. Run the installation command again.

$ sudo apt install phpmyadmin
  1. Use this command to enable the password component again in MySQL.

INSTALL COMPONENT "file://component_validate_password";

d. To setup the mbstring PHP extension, type the following command:

$ sudo phpenmod mbstring

e. You need to restart your Apache server by running the following command.

$ sudo systemctl restart apache2

phpMyAdmin is installed and set up to pair with Apache. You now have to make sure that users in your MySQL have the permissions necessary for working with the application before you can log in and start working with your MySQL databases.

Step 2 : Initial Setup and User Authentication

a. To open phpMyAdmin in your browser, follow these steps to setup a password-based access by creating an account to login:-

$ sudo mysql

b. Check access levels of existing accounts by using the below command:

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

c. To setup a password for root account, use the below commands.

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';

Or if you have an older version try:

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

d. Now, check again the list of existing accounts to confirm.

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

e. Follow these steps for making a user for separate access to phpMyAdmin.

$ sudo mysql

Or if you have a password setup use:

$ mysql -u root -p

f. Type this command to create a user.

CREATE USER 'john'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'your_password';

Again, if you have an older version try:

ALTER USER 'john'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';

g. To grant suitable privileges to your user, type the following command:

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

h. After this you can exit MySQL and run phpMyAdmin in your browser.

mysql> exit

i. To access phpMyAdmin interface from your browser, type your IP address, or your server's IP address, or your domain followed by /phpMyAdmin.

your_domain_or_IP/phpmyadmin

Conclusion

After it has been set up, your Ubuntu 20.04 server must now be prepared to use phpMyAdmin. Using this interface, you may do common tasks including deleting and altering present structures and data in addition to creating databases, users, and tables.

Last updated