π’οΈ 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
-
Download the installer from mariadb.org.
-
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
π Connecting to MariaDB
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
PHP See β Php.md
You can also connect using:
-
Node.js:
mysql2
orsequelize
-
Python:
mysql-connector-python
orSQLAlchemy
-
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
inUPDATE
/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.
"MariaDB is MySQLβs wiser sibling β open, community-led, and scalable for the real world."
Explore more features in the official docs.