Introduction
phpMyAdmin is a free, open-source tool developed in PHP that allows you to manage MySQL or MariaDB databases via a web browser. It provides an intuitive interface for performing tasks such as creating, modifying, and deleting databases, tables, and records, executing SQL queries, and managing users and permissions.
Setup
Before using phpMyAdmin, ensure that the LAMP stack (Linux, Apache, MySQL, PHP) is installed on your server. If not, you can follow a tutorial to set it up here.
1. Update the System
Start by updating your server to ensure all packages are up to date. Run the following command:
sudo apt-get update && sudo apt-get upgrade -y
2. Install phpMyAdmin
Install phpMyAdmin with the following command:
sudo apt-get install phpmyadmin
During the installation process, you will be prompted to configure phpMyAdmin:
- Select Apache2 as the server.
- Choose YES when asked to configure the database for phpMyAdmin using dbconfig-common.
- Enter your MySQL root password when prompted.
- Set a password for logging into phpMyAdmin.
3. Configure Apache
After the installation, you need to include phpMyAdmin in Apache's configuration. Open the Apache configuration file:
sudo nano /etc/apache2/apache2.conf
If nano
is not installed, you can install it with:
sudo apt-get install nano
Add the following line to the bottom of the file:
Include /etc/phpmyadmin/apache.conf
Save and exit the file. Then, restart Apache to apply the changes:
sudo service apache2 restart
You can verify the installation by visiting:
http://[your_server_IP]/phpmyadmin
4. Enhance Security
Older versions of phpMyAdmin have had security vulnerabilities, making it essential to secure the directory. One way to enhance security is by restricting access to the phpMyAdmin directory using an .htaccess
file.
To secure your phpMyAdmin directory, edit the Apache configuration file for phpMyAdmin:
sudo nano /etc/phpmyadmin/apache.conf
Add the following lines to allow access only from specific IP addresses:
order allow,deny
allow from your_IP_address
Accessing phpMyAdmin
To access phpMyAdmin, open a web browser and navigate to:
http://[your_server_IP]/phpmyadmin
You will be prompted to enter a username and password. Use "root" and the MySQL root password you set during installation, or log in with any other MySQL user credentials.
If you can log in successfully, phpMyAdmin has been installed and configured correctly.