MariaDB Tutorial: Installing and Setting Up MariaDB
In this tutorial, we will cover how to install and set up MariaDB on a Linux system. MariaDB is an open-source relational database management system that is based on the MySQL database management system.
Step 1: Install MariaDB To install MariaDB on a Linux system, you will need to use a package manager such as apt
or yum
. The specific command you will use will depend on the distribution you are using. For example, on a Debian-based system, you can use the following command to install MariaDB:
sqlCopy codesudo apt update
sudo apt install mariadb-server
Step 2: Start MariaDB Once you have installed MariaDB, you can start the MariaDB service using the following command:
sqlCopy codesudo systemctl start mariadb
Step 3: Secure MariaDB After starting the MariaDB service, it is important to secure the installation. You can do this using the mysql_secure_installation
script. To run this script, use the following command:
Copy codesudo mysql_secure_installation
This script will prompt you to set a root password for MariaDB, remove anonymous user accounts, and disallow remote root logins.
Step 4: Connect to MariaDB Once you have secured your MariaDB installation, you can connect to the MariaDB server using the mysql
client. To connect to the MariaDB server, use the following command:
cssCopy codemysql -u root -p
You will be prompted to enter the root password you set during the mysql_secure_installation
script.
Step 5: Create a Database and Table Now that you have connected to MariaDB, you can create a database and table. To create a database, you can use the following SQL statement:
sqlCopy codeCREATE DATABASE mydatabase;
To create a table, you can use the following SQL statement:
sqlCopy codeUSE mydatabase;
CREATE TABLE mytable (
id INT PRIMARY KEY,
name VARCHAR(255),
age INT
);
This will create a database named mydatabase
and a table named mytable
in that database. The table has three columns: id
, name
, and age
. The id
column is the primary key, which means that it is used to uniquely identify rows in the table.
Conclusion In this tutorial, we covered how to install and set up MariaDB on a Linux system. We installed MariaDB, started the MariaDB service, secured the installation, connected to the MariaDB server, and created a database and table. This should provide a good foundation for further exploration and experimentation with MariaDB.