phpMyAdmin is a free, open-source software administration tool for handling operations for MySQL and MariaDB database servers. These operations include creating and managing databases, adding user accounts, and running queries.
phpMyAdmin is a good choice for Database administrators as it allows them to control users and operates different servers at the same time. It also allows them to export data in different formats like XML, CSV, and PDF

Features

  • It can run on any server as it has a web browser interface.
  • It is translated into 72 different languages.
  • It has a flexible codebase making it stable.
  • Good documentation.
  • Supports most MySQL and MariaDB features.
  • Creating graphics for the database layouts.
  • Display multiple results sets through stored procedures and queries.

This guide will show you how to install phpMyAdmin on KDE Neon|Kubuntu.

Setup Pre-requisites

To install phpMyAdmin, you should have installed the LAMP stack on your KDE|Kubuntu system. If not, follow through with this guide on How To Install LAMP Stack on KDE Neon|Kubuntu. If you already have the LAMP stack installed on your system, proceed with the next steps.

Install phpMyAdmin on KDE Neon / Kubuntu

Update your system packages.

### Kubuntu ###
sudo apt update && sudo apt upgrade -y

### KDE Neon ###
sudo apt update && sudo pkcon update -y

Then install phpMyAdmin and some external packages using the following command.

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

You will be prompted to choose a web server. Press space to select Apache2 then TAB to move to the OK then press enter to continue.

Then you will also be prompted to configure the database. Press Enter to continue

The set the password for the database

Then you will be prompted to confirm the password. Type it and press enter. to finish the installation.

Enable the php-mbstring using the following command.

sudo phpenmod mbstring

Then restart the webserver

sudo systemctl restart apache2

When installing phpMyAdmin it automatically creates a database named phpmyadmin which you can use to log in on the first attempt.

Access phpMyAdmin web interface on KDE Neon / Kubuntu

Then head over to your browser and use http://<your-server-ip>/phpmyadmin or your localhost/phpmyadmin to load phpMyAdmin.

Then login in with phpmyadmin as the username and the password you set above for the database.

Create a different phpMyAdmin user

Now, if you don’t want to use the default phpmyadmin user, you can create a separate user. Login to MySQL

sudo mysql -u root -p

Then copy the following commands to create a user with a password and allow privileges.

CREATE USER 'testuser'@'localhost' IDENTIFIED by 'PassCode';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Now you can log in with the new credentials.

Secure phpMyAdmin on KDE Neon / Kubuntu

To add extra security phpMyAdmin from attacks, Enable an additional login in front of the application using Apache’s built-in .htaccess authentication and authorization features.

We will modify the phpMyAdmin configuration file to enable the .htaccess file override.

sudo nano /etc/apache2/conf-available/phpmyadmin.conf

Add the AllowOverride line under the <Directory /usr/share/phpmyadmin>

<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
AllowOverride All

Save and exit the file by pressing CTRL+X then Y then Enter. Restart the webserver to implement changes.

sudo systemctl restart apache2

Then create a .htaccess file in the phpMyAdmin application directory using the following command:

sudo nano /usr/share/phpmyadmin/.htaccess

Enter the following information then save the file.

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

Now pass the file to the initial user with the htpasswd utility. Use your username.

sudo htpasswd -c /etc/phpmyadmin/.htpasswd ann

Now restart the webserver to accept changes.

sudo systemctl restart apache2

Then trying to access the interface will prompt an authentication dialog for a user to sign in.

Create a Database on phpMyAdmin

To create a database, click on New and enter the name of the database then click Go.

To create a table use the following CREATE command under the SQL query tab.

CREATE TABLE staff (
    id INT NOT NULL PRIMARY KEY, 
    first_name VARCHAR (255) NOT NULL,
    last_name VARCHAR (255) NOT NULL,
    role VARCHAR (255) NOT NULL
); 

The table will appear under the new database as shown below.

To insert multiple rows into the table, use the following INSERT command

INSERT INTO staff
  ( id, first_name, last_name, role )
VALUES
  (123, 'John', 'McGavin', 'Database Admin'), 
  (456, 'Jane', 'Kamau', 'System Admin'), 
  (789, 'Billy', 'Walter', 'Network Admin'),
  (101, 'Miranda', 'Spice', 'Project Manager');

Display the fields using the following SELECT command.

SELECT * FROM `staff` 

The data fields will be displayed as shown.

Conclusion

From this guide, You have learned how to install phpMyAdmin on KDE Neon|Kubuntu. phpMyAdmin is a free and open-source data administration tool with an intuitive web interface. We have gone through the process of adding a separate user to log in to the web interface and also learned how to secure it from cyberattacks.

Check more articles in links below:

LEAVE A REPLY

Please enter your comment!
Please enter your name here