Logo

How To Install MariaDB on CentOS 7

Apr 04, 2024

To install MariaDB on CentOS 7, follow the steps below:

Step 1 : Begin by updating the system's package index:

sudo yum update

Step 2 : Install MariaDB server using the following command:

sudo yum install mariadb-server

Step 3 : Start the MariaDB service and enable it to start on boot:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 4 : Run the following command to secure your MariaDB installation:

sudo mysql_secure_installation

Follow these prompts:

- Enter the root password (leave blank if not set).

- Change the root password: choose 'y'.

- Remove anonymous users: choose 'y'.

- Disallow root login remotely: choose 'y'.

- Remove test database and access to it: choose 'y'.

- Reload privilege tables now: choose 'y'.

Step 5 : Verify that MariaDB is running correctly:

sudo systemctl status mariadb

Step 6 : Access the MariaDB shell with the following command:

sudo mysql -u root -p

Step 7 : Inside the MariaDB shell, you can create a new admin user and grant necessary privileges:

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Congratulations! You have successfully installed MariaDB on CentOS 7.