The native tool for access MySQL or MariaDB databases is the command-line. With a few commands, you can access the database shell and perform a variety of tasks including viewing and creating databases and database users. However, not everyone is a fan of the command-line, and this is where phpMyAdmin is beneficial.
Written in PHP, phpMyAdmin is a wonderful free and open-source tool that provides a front-end web interface to MySQL or MariaDB. It allows users to log in and easily perform database management tasks such as managing databases, users, and permissions to mention a few. and user creation. In this guide, we delve into the installation of phpMyAdmin.
PhpMyAdmin is PHP-driven and runs on the front-end. As such, ensure that you have installed LAMP on Ubuntu 20.04. If you don’t have it already, please head over to our article on How to install LAMP.
Additionally, ensure that you have configured a sudo user on your instance of Ubuntu 20.04.
Step 1: Install PhpMyAdmin
Firstly, access your terminal and update your package lists using the command provided.
$ sudo apt update
The phpMyAdmin package is available on Ubuntu repositories, therefore, use the APT package manager to install it as follows.
$ sudo apt install phpmyadmin
Along the way, you will encounter some prompts. First, choose your preferred web server. Since you already have Apache installed, press the TAB key on the ‘Apache’ option and hit ENTER.
The phpMyAdmin package requires the installation and configuration of a database before use. Manual configuration is hectic and tedious. Thankfully, the setup provides you an option to configure the database using the dbconfig-common which simplifies the configuration.
Select the ‘Yes’ option to tweak the phpMyAdmin database with the dbconfig-common package and hit ENTER.
Thereafter, provide the password for phpMyAdmin.
And then confirm it as shown.
The installation will then continue with the installation of the required packages, dependencies and PHP extensions that will be required by phpMyAdmin.
Once the installation is complete, a new database called phpmyadmin is created with the user phpmyadmin. If you want to feed your curiosity, proceed and access your database as shown.
$ sudo mysql -u root -p
To display the existing databases execute the MySQL command as follows.
> show databases;
Be sure to locate the phpmyadmin database as seen in the snippet provided.
Additionally, you can view the privileges assigned to the phpmyadmin user on the phpmyadmin database by invoking:
> show grants for phpmyadmin@localhost;
Step 2: Verify successful installation of PhpMyAdmin
To ensure that the installation was successful, run the following command to confirm that the phpmyadmin.conf configuration file exists.
$ file /etc/apache2/conf-enabled/phpmyadmin.conf
The output should appear as follows providing you with the full path to the configuration file and the symbolic link it points to.
Step 3: Access PhpMyAdmin from a browser
The last step in the installation is to access the phpMyAdmin interface. On your browser, browse the address shown:
The phpMyadmin login page comes to view as shown. Use the root credentials to log in.
If you encounter an error while logging into phpMyAdmin, follow the steps provided:
First, access the MySQL database as shown:
$ sudo mysql -u root -p
Thereafter proceed and create a new database user :
> CREATE USER 'user'@'localhost' IDENTIFIED BY 'your-password;
Next, accord all privileges to the user as shown
> GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';
Finally, flush privileges and exit the shell.
> FLUSH PRIVILEGES
Once logged in, you will be presented with the phpMyAdmin panel as shown below.
It’s our hope that this tutorial was insightful and that you can seamlessly install phpMyAdmin on your system.