Installation guides

Installing MariaDB on Debian

Step-by-Step Guide

  1. Update the Package Index
    Open a terminal and update the package index to ensure you have the latest information about available packages:
   sudo apt update
  1. Install MariaDB
    Install MariaDB using the apt package manager:
   sudo apt install mariadb-server
  1. Secure MariaDB Installation
    Run the security script that comes pre-installed with MariaDB to improve the security of your installation:
   sudo mysql_secure_installation

This script will prompt you to set a root password, remove anonymous users, disallow root login remotely, remove test databases, and reload the privilege tables. Follow the prompts and answer accordingly.

  1. Verify MariaDB Installation
    Check the MariaDB service status to ensure it is running:
   sudo systemctl status mariadb

If MariaDB is running, you should see an active (running) status.

  1. Log In to MariaDB
    Log in to the MariaDB root administrative account:
   sudo mysql -u root -p

You will be prompted to enter the root password you set during the secure installation process.

  1. Create a New Database (Optional)
    To create a new database, use the following SQL command within the MariaDB prompt:
   CREATE DATABASE your_database_name;
  1. Create a New MariaDB User (Optional)
    To create a new MariaDB user and grant it permissions, use the following SQL commands:
   CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
   GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost';
   FLUSH PRIVILEGES;

This will create a new user and grant them all privileges on the specified database.

  1. Test MariaDB
    To verify that MariaDB is functioning correctly, exit the MariaDB prompt and try logging in as the new user:
   mysql -u your_username -p

You will be prompted to enter the password for the new user. Once logged in, you can list the available databases to ensure your new database is present:

   SHOW DATABASES;
  1. Backup and Restore Databases (Optional)
    To back up a database, use the mysqldump command:
   mysqldump -u your_username -p your_database_name > your_database_name.sql

To restore a database from a backup file, use the mysql command:

   mysql -u your_username -p your_database_name < your_database_name.sql
Other Recent Posts