
{{ $('Map tags to IDs').item.json.title }}
Installing MariaDB on Debian and Ubuntu
MariaDB is a robust, scalable, and open-source relational database management system that serves as a drop-in replacement for MySQL. This tutorial will guide you through the process of installing MariaDB on Debian and Ubuntu systems.
Prerequisites
- A Debian or Ubuntu server with terminal access.
- Root or sudo privileges to install software.
1. Update Your Package Index
Before installing MariaDB, update your package index to ensure you are installing the latest version:
sudo apt update
2. Installing MariaDB
You can install MariaDB directly from the default repositories using the following command:
- For Ubuntu:
sudo apt install mariadb-server -y
- For Debian:
sudo apt install mariadb-server -y
3. Securing your MariaDB Installation
After the installation is complete, it is important to secure your MariaDB server. Run the security script:
sudo mysql_secure_installation
This script will prompt you to:
- Set a root password (if not already set).
- Remove anonymous users.
- Disable root login remotely.
- Remove the test database.
- Reload privilege tables.
4. Testing Access to MariaDB
To log in to the MariaDB server as the root user, run:
sudo mysql -u root -p
Enter the root password when prompted. If you can log in, the installation was successful.
5. Creating a New Database and User
Once logged in, you can create a new database and user for your applications:
CREATE DATABASE my_database;
CREATE USER 'my_user'@'localhost' IDENTIFIED BY 'my_password';
GRANT ALL PRIVILEGES ON my_database.* TO 'my_user'@'localhost';
FLUSH PRIVILEGES;
Replace my_database
, my_user
, and my_password
with your desired database name, username, and password.
6. Configuring MariaDB to Start on Boot
MariaDB is typically configured to start on boot by default. To ensure it is enabled, run:
sudo systemctl enable mariadb
7. Restarting MariaDB
If you need to restart the MariaDB service, use:
sudo systemctl restart mariadb
8. Conclusion
You have successfully installed and configured MariaDB on your Debian or Ubuntu server. MariaDB is now ready for use as a powerful database engine for your applications. Continue exploring MariaDB’s features to take full advantage of its capabilities.