Install MariaDB and phpMyAdmin on Debian 13 for Laravel
verified on 2 September 2026 · 4 min
sudo apt install mariadb-server, then sudo mariadb-secure-installation (the old mysql_secure_installation is gone). Create a utf8mb4 database and a dedicated user limited to that database, never the administrator account. On the Laravel side, DB_CONNECTION=mysql is the right value for MariaDB too.
Laravel needs a database. On Debian, MariaDB is the default choice: it is the package the distribution ships, and it works with the MySQL driver Laravel already uses. phpMyAdmin comes afterwards, if you want a web interface to inspect your tables.
This chapter is part of installing Laravel on a Debian server, in the Web development track. The steps were run on Debian 13 “trixie” with MariaDB 11.8.6 and Laravel 13.30.1, on 2 September 2026.
Install MariaDB
sudo apt update
sudo apt install -y mariadb-server
sudo systemctl enable --now mariadb
mariadb --versionmariadb from 11.8.6-MariaDB, client 15.2 for debian-linux-gnuThe administrator account is reachable from the root shell of the machine, with no password. That does not make the installation safe: it means the security rests entirely on who can get onto the server.
Secure the installation
Debian 13 ships the tool under its MariaDB name. The old mysql_secure_installation is gone:
sudo mariadb-secure-installationThe script asks a series of questions. Answer them like this:
| Question | Answer | Why |
|---|---|---|
| Switch to unix_socket authentication | yes | the administrator authenticates through their system account, not through a stored password |
| Change the root password | up to you | pointless once unix_socket is enabled |
| Remove anonymous users | yes | they allow a connection with no credentials |
| Disallow root login remotely | yes | administration happens over SSH, not on port 3306 |
| Remove test database | yes | a database anyone can write to |
| Reload privilege tables | yes | applies the changes straight away |
Create the database and the application user
Never run the application under the administrator account. Create a dedicated database and a dedicated account:
sudo mariadbCREATE DATABASE laravel
CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
CREATE USER 'laravel'@'localhost' IDENTIFIED BY 'un_mot_de_passe_long';
GRANT ALL PRIVILEGES ON laravel.* TO 'laravel'@'localhost';
FLUSH PRIVILEGES;Two details are worth a second look. The utf8mb4 character set is not decoration: it is the only one that stores the whole of Unicode, emoji included. And the privilege is restricted to laravel.*, not *.*: if the application is ever compromised, the other databases stay out of reach.
Check the result:
SHOW GRANTS FOR 'laravel'@'localhost';GRANT USAGE ON *.* TO `laravel`@`localhost` IDENTIFIED BY PASSWORD '*1F48A8…'
GRANT ALL PRIVILEGES ON `laravel`.* TO `laravel`@`localhost`Wire Laravel up
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=laravel
DB_PASSWORD=un_mot_de_passe_longDB_CONNECTION=mysql is the right value for MariaDB too: Laravel goes through the same PDO driver. Clear the configuration cache, then run the migrations:
php artisan config:clear
php artisan migrate --force INFO Running migrations.
0001_01_01_000000_create_users_table ......................... 136.15ms DONE
0001_01_01_000001_create_cache_table .......................... 65.58ms DONE
0001_01_01_000002_create_jobs_table .......................... 117.52ms DONEMigrations that go through are proof that the connection, the privileges and the character set are all correct.
A “could not find driver” error does not come from MariaDB but from PHP: php-mysql is missing. Check with php -r 'echo implode(", ", PDO::getAvailableDrivers());', as covered in the chapter on PHP and its extensions, and make sure mysql shows up. The php-mysqli package is not enough, since Laravel goes through PDO.
phpMyAdmin, and whether you need it
phpMyAdmin is back in Debian 13, in version 5.2.2:
sudo apt install -y phpmyadminThe installer offers to configure the web server, Apache in the most common case, and creates its own configuration database. On an Apache install the interface is then served under /phpmyadmin.
The /phpmyadmin address is scanned around the clock. If you install it on a public server, restrict access by IP address or HTTP authentication, or do not expose it at all: an SSH tunnel lets you reach it from your own machine without opening it to the world.
# SSH tunnel: phpMyAdmin stays on the server's loopback interface
ssh -L 8080:127.0.0.1:80 deploy@exemple.com
# then http://127.0.0.1:8080/phpmyadmin from your browserFor day-to-day work the command line is enough, and it sidesteps the question entirely:
sudo mariadb laravel -e "SHOW TABLES;"
php artisan db:show
php artisan db:table users
php artisan tinkerphp artisan db:show lists the tables, their size and their row count without leaving the terminal. That is usually all you need.
Back the database up
A database without a backup is not a production database. The bare minimum:
sudo mariadb-dump --single-transaction laravel | gzip > /var/sauvegardes/laravel-$(date +%F).sql.gz--single-transaction avoids locking InnoDB tables during the export, so the service keeps running while the backup is taken. Put that line in a scheduled job, and check from time to time that a restore really works: a backup you have never restored is a hypothesis, not a guarantee.
Common errors
mariadb-secure-installation.laravel.*.php-mysql is missing. php-mysqli is not enough, since Laravel goes through PDO.