To set up MariaDB on a Debian system, you can follow these steps:
Start by updating your package index to make sure you’re working with the latest package lists:
sudo apt update
MariaDB is available in the default Debian repositories, so you can install it using the apt
package manager:
sudo apt install mariadb-server
After the installation, you need to run a security script that comes with MariaDB to remove insecure default settings. This will allow you to set a root password, remove test databases, and disable anonymous users.
sudo mysql_secure_installation
During the process, you will be prompted to:
Find more about MariaDB Security
Make sure the MariaDB service is running and enabled to start on boot:
sudo systemctl start mariadb
sudo systemctl enable mariadb
Log in to MariaDB to ensure everything is working:
sudo mysql -u root -p
You’ll be prompted for the root password you set during the secure installation process.
If you want to customize MariaDB settings, you can do so by editing the configuration file:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
After making any changes, restart the MariaDB service:
sudo systemctl restart mariadb
If you plan on accessing MariaDB remotely, ensure the firewall allows traffic on the default MariaDB port (3306):
sudo ufw allow 3306/tcp
That’s it! MariaDB should now be installed and running on your Debian system.