Install MariaDB on CentOS 7: Step-by-Step Guide
To install and configure MariaDB database on CentOS7, follow the steps below:
- Update the system software packages.
sudo yum update
- Install the MariaDB database:
sudo yum install mariadb-server
- Start the MariaDB service and set it to start automatically at boot.
sudo systemctl start mariadb
sudo systemctl enable mariadb
- Run a security script to enhance database security and set up a password as instructed.
sudo mysql_secure_installation
- Access the MariaDB database:
sudo mysql -u root -p
- Create new users and databases in MariaDB.
CREATE DATABASE dbname;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
- Exit MariaDB database and log back in to verify if the new user and database have been successfully created.
exit
sudo mysql -u username -p
USE dbname;
You have now successfully installed and configured the MariaDB database on CentOS 7. You can now start creating tables and inserting data into this database.