Install MARIADB on UBUNTU

How to Install MariaDB on Ubuntu

Step 1: Update Your System

Before installing MariaDB, it's a good practice to update your system to ensure you have the latest package information:

sudo apt update
sudo apt upgrade -y

Step 2: Install MariaDB Server

Install MariaDB Server on Ubuntu using the following command:

sudo apt install -y mariadb-server

Step 3: Start and Enable MariaDB

After installing MariaDB, start the MariaDB service and enable it to start automatically on boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 4: Secure Your MariaDB Installation

Run the MariaDB secure installation script to secure your installation:

sudo mysql_secure_installation

Follow the prompts to set a root password and secure your MariaDB installation.

Step 5: Test MariaDB

Test your MariaDB installation by logging in as the root user:

sudo mysql -u root -p

Enter the root password you set during the secure installation.

Step 6: Create Databases and Users (Optional)

Create databases and user accounts in MariaDB as needed:

CREATE DATABASE mydatabase;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;

Step 7: Exit MariaDB

Exit the MariaDB console:

exit

Step 8: Start and Enable MariaDB on Boot

If the MariaDB service is not already running, you can start it and enable it to start automatically on boot with these commands:

sudo systemctl start mariadb
sudo systemctl enable mariadb

That's it! You've successfully installed and configured MariaDB on Ubuntu. You can now use MariaDB to create databases, manage user accounts, and run SQL queries on your server.

Related Articles