Ga naar inhoud

phpMyAdmin

In deze handleiding leer je hoe je phpMyAdmin kunt installeren en configureren op een Linux-systeem.
We gebruiken Debian/Ubuntu als voorbeeld met Apache2 en PHP 8.2.

Wat is phpMyAdmin?

  • phpMyAdmin is een webgebaseerde interface voor het beheren van MySQL/MariaDB-databases.
  • Het maakt databasebeheer eenvoudig via een browser (gebruikers, tabellen, rechten, import/export).
  • Werkt met Apache of Nginx + PHP.

1. Installatie

sudo apt update
sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl
Voorbeeld output
The following additional packages will be installed:
  dbconfig-common php-tcpdf php8.2-bz2 php8.2-mbstring ...
Setting up phpmyadmin (4:5.2.1+dfsg-1) ...

2. Apache configureren

Tijdens de installatie krijg je de vraag om Apache2 of Lighttpd te configureren.
Kies hier Apache2 en druk op Enter.

Als je handmatig een config wilt maken:

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

Voeg toe:

Include /etc/phpmyadmin/apache.conf

Activeer de configuratie en herstart Apache:

sudo a2enconf phpmyadmin
sudo systemctl reload apache2

3. MySQL/MariaDB configuratie

Log in op MySQL:

sudo mysql -u root -p

Maak een gebruiker aan:

CREATE USER 'pmauser'@'localhost' IDENTIFIED BY 'SterkWachtwoord123!';
GRANT ALL PRIVILEGES ON *.* TO 'pmauser'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

4. phpMyAdmin testen

Ga in de browser naar:

http://jouw-server-ip/phpmyadmin

Log in met de eerder gemaakte gebruiker of de root-gebruiker (indien ingeschakeld).


5. Beveiliging

Om bots te vermijden kun je de toegangspad aanpassen:

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

Vervang /phpmyadmin door bijvoorbeeld /dbbeheer.

Alias /dbbeheer /usr/share/phpmyadmin

Herstart Apache:

sudo systemctl reload apache2
<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
    <IfModule mod_php7.c>
        AddType application/x-httpd-php .php
    </IfModule>
    <IfModule mod_php8.c>
        AddType application/x-httpd-php .php
    </IfModule>
    <IfModule mod_authz_core.c>
        <RequireAny>
            Require ip 192.168.1.0/24
            Require ip 127.0.0.1
        </RequireAny>
    </IfModule>
</Directory>

6. phpMyAdmin verwijderen

sudo apt purge phpmyadmin
sudo rm -rf /etc/phpmyadmin /usr/share/phpmyadmin
Voorbeeld output
The following packages will be REMOVED:
  phpmyadmin*
After this operation, 25.0 MB disk space will be freed.

Conclusie

✅ Je hebt nu een veilige installatie van phpMyAdmin werkend op je server.
Je kunt MySQL/MariaDB eenvoudig beheren via de browser.