Mariadb

πŸ›’οΈ MariaDB Sheet

[!info]
MariaDB is a robust, open-source relational database system. It’s a community-driven fork of MySQL, known for performance, reliability, and compatibility with existing MySQL setups.


πŸš€ Introduction

MariaDB is used for storing, retrieving, and managing data efficiently. It’s a popular choice for web development, enterprise apps, and embedded systems.


🧰 Installation

πŸͺŸ Windows

  1. Download the installer from mariadb.org.

  2. Run and follow the on-screen steps.

🍎 macOS (Homebrew)

brew install mariadb

🐧 Ubuntu (20.04 LTS+)

sudo apt update
sudo apt install mariadb-server
sudo mysql_secure_installation

🎩 RHEL / CentOS

sudo yum install mariadb-server

mysql -u your_username -p

You'll be prompted for your password.


🌍 Remote Access

[!warning]
Be cautious when opening DB ports publicly. Secure with firewalls and IP allowlists.

Edit /etc/mysql/mariadb.conf.d/50-server.cnf:

bind-address = 0.0.0.0

πŸ§‘β€πŸ’» Connect via Code

[!example] PHP See β†’ Php.md

You can also connect using:

  • Node.js: mysql2 or sequelize

  • Python: mysql-connector-python or SQLAlchemy

  • Java: JDBC drivers


πŸ‘‘ Create Administrative User

CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
FLUSH PRIVILEGES;

πŸ—οΈ Database Operations

βž• Create Database

CREATE DATABASE your_database_name;

πŸ“ Select Database

USE your_database_name;

🧱 Table Operations

πŸ“„ Create Table

CREATE TABLE your_table_name (
  column1 datatype1 constraints,
  column2 datatype2 constraints
);

βž• Insert Data

INSERT INTO your_table_name (column1, column2) VALUES (value1, value2);

πŸ” Query Data

SELECT column1, column2 FROM your_table_name WHERE condition;

✏️ Update Data

UPDATE your_table_name SET column1 = new_value1 WHERE condition;

❌ Delete Data

DELETE FROM your_table_name WHERE condition;

🧠 Tips and Best Practices

[!tip]

  • Always use WHERE in UPDATE/DELETE to avoid affecting all rows.

  • Backup databases regularly using mysqldump.

  • Secure remote access with SSL and user-based permissions.


πŸ“˜ Conclusion

MariaDB offers an approachable, powerful platform for managing structured data. Whether you're building web apps, running internal tools, or learning SQL, it’s an excellent RDBMS to master.

[!quote] "MariaDB is MySQL’s wiser sibling β€” open, community-led, and scalable for the real world."

Explore more features in the official docs.



🌍 Explore More


🏷️ Tags πŸ“š

#mariadb #mysql #sql #databases #devops #linux #webdev #php