Jay Abhani
Senior Web Development Instructor at almaBetter
Master MariaDB with our MariaDB cheat sheet! Learn essential commands, SQL injection prevention and markdown tips for efficient database management in our guide
MariaDB is a powerful, open-source relational database management system (RDBMS) widely used for web applications, analytics, and more. This cheat sheet is designed to help you quickly reference important MariaDB commands, SQL injection techniques, and relevant Markdown formatting tips for documentation. This guide integrates essential topics for beginners and advanced users alike.
MariaDB is a fork of MySQL designed to provide improved performance, scalability, and enhanced features. It uses SQL as its query language and is compatible with most MySQL tools and frameworks. MariaDB is available for Windows, Linux, and macOS.
sudo apt update
sudo apt install mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb
brew install mariadb
brew services start mariadb
Secure your MariaDB installation:
sudo mysql_secure_installation
mysql -u <username> -p
SHOW DATABASES;
CREATE DATABASE database_name;
USE database_name;
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
...
);
INSERT INTO table_name (column1, column2) VALUES ('value1', 'value2');
SELECT * FROM table_name;
UPDATE table_name SET column1 = 'value' WHERE condition;
DELETE FROM table_name WHERE condition;
mysqldump -u <username> -p database_name > backup.sql
mysql -u <username> -p database_name < backup.sql
DROP DATABASE database_name;
ALTER TABLE table_name ADD column_name datatype;
ALTER TABLE table_name DROP column_name;
SELECT COUNT(column_name), SUM(column_name), AVG(column_name)
FROM table_name;
SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column;
SELECT * FROM table1 LEFT JOIN table2 ON table1.column = table2.column;
SELECT * FROM table1 RIGHT JOIN table2 ON table1.column = table2.column;
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'host';
SHOW GRANTS FOR 'username'@'host';
REVOKE ALL PRIVILEGES ON database_name.* FROM 'username'@'host';
SQL injection is a security vulnerability that allows attackers to interfere with queries. Here’s a cheat sheet to understand and prevent SQL injection in MariaDB.
' OR '1'='1
' OR '1'='1' --
UNION SELECT schema_name FROM information_schema.schemata;
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = :username");
$stmt->bindParam(':username', $username);
SELECT JSON_EXTRACT(json_column, '$.key') FROM table_name;
ALTER TABLE table_name ADD COLUMN dynamic_column BLOB;
DELIMITER //
CREATE PROCEDURE procedure_name()
BEGIN
-- SQL statements
END //
DELIMITER ;
Markdown is a lightweight markup language for creating formatted text. Documenting your MariaDB workflows in Markdown ensures clarity and ease of sharing.
# Heading 1
## Heading 2
**Bold** and *Italic*
`Inline code`
SELECT * FROM table_name;
This comprehensive MariaDB cheat sheet covered essential commands, SQL injection techniques, and a Markdown guide for effective documentation. Whether you're a beginner or a seasoned user, keeping this guide handy will improve your workflow and help secure your database systems.
More Cheat Sheets and Top Picks