MongoDB Two Phase Commit: The Old Pattern vs Real Transactions

MongoDB two phase commit pattern recovering a crashed transfer between two accounts

Skip the hand-rolled MongoDB two phase commit unless you’re on a standalone server or a version older than 4.0. A real multi-document transaction did the same transfers 3 to 6 times faster in my runs. Quick answer: the pattern logs each transfer in a transactions collection, walks it through initial, pending, applied and done, and … Read more >>

How to Get the ID After Insert in MongoDB (insertedId, PyMongo)

Get id after insert in MongoDB with insertOne insertedId in mongosh

My first try printed result._id and mongosh answered undefined. The id was there all along, just under another name. The fix for “get id after insert MongoDB“: read insertedId from the insertOne() result, or insertedIds from insertMany(). No second query: Tested on MongoDB 9.0.4 with mongosh 2.14 and PyMongo 4.19 on Windows. Get the _id … Read more >>

MariaDB Create Database and User (With GRANT and Login Test)

MariaDB create database and user with GRANT ALL PRIVILEGES and SHOW GRANTS in VS Code

Every new app should get its own MariaDB database and its own login, so a bug in one app can’t read or drop another app’s tables. Quick answer: run CREATE DATABASE app_db;, then CREATE USER ‘app’@’localhost’ IDENTIFIED BY ‘password’; and GRANT ALL PRIVILEGES ON app_db.* TO ‘app’@’localhost’;. You don’t need FLUSH PRIVILEGES. In this tutorial, … Read more >>

MariaDB Migration Tool

MariaDB Migration Tool

How the choice of a MariaDB migration tool can make or break your project timeline. In this guide, I will walk you through the landscape of MariaDB migration, the tools that define the industry standard, and a comprehensive tutorial on how to execute a professional-grade migration. MariaDB Migration Tool We are seeing a massive shift … Read more >>

How to use Maria DB

How to use Maria DB

Choosing the right relational database management system (RDBMS) is a critical decision for any tech-driven enterprise. MariaDB has emerged as the high-performance, community-driven alternative that many of us in the industry now prefer. In this article, I’m going to guide you through the essentials of using MariaDB, from installation to advanced administration. How to use … Read more >>

MariaDB GUI Tools: HeidiSQL, DBeaver, phpMyAdmin Compared

MariaDB GUI HeidiSQL connected with a read-only login

If you need a MariaDB GUI on Windows, use HeidiSQL: the MariaDB installer already put it on your disk. On a Mac or Linux box, or when you also manage PostgreSQL or SQL Server, pick DBeaver Community instead. That’s my verdict after connecting HeidiSQL 12.20.0.7320 to MariaDB 13.0.2 on Windows 11 and logging every statement … Read more >>

MongoDB Backup and Restore with mongodump and mongorestore

MongoDB backup and restore with mongodump and mongorestore in VS Code

Back up with mongodump, restore with mongorestore. That’s the whole MongoDB backup and restore loop for one database: Tested on MongoDB 9.0.4 (standalone, Windows 11), mongosh 2.14 and Database Tools 100.20.1. Here’s the end state after I dropped a database and restored it: Before You Start: Sample Database and Tools Since MongoDB 4.4 the dump … Read more >>

What Is MariaDB? Uses, Features and How It Differs From MySQL

What is MariaDB: system-versioned table query in a real MariaDB 13.0.2 run

What is MariaDB? It’s a free, open-source relational database that started in 2009 as a fork of MySQL, built by MySQL’s original developers and licensed under the GPLv2. The project calls it a drop-in replacement for MySQL. I wanted to see what the current release actually ships with, so I ran it on Windows. Quick … Read more >>

MariaDB DROP TABLE: IF EXISTS, Foreign Keys, TEMPORARY, Rollback

MariaDB DROP TABLE foreign key error 1451 run in VS Code

Many guides still add CASCADE to a MariaDB drop table statement. MariaDB accepts it and ignores it. Use IF EXISTS, and clear foreign keys first: My run: MariaDB 13.0.2, InnoDB tables, Windows 11. The Sample Store Tables Five plain MariaDB tables. Only orders has a foreign key, pointing at customers: MariaDB DROP TABLE Syntax WAIT … Read more >>

Drop Constraint in MariaDB: FK, UNIQUE, PK, CHECK Errors Fixed

MariaDB drop constraint errors 1025 and 1075 reproduced in VS Code

You copied the constraint name from memory, ran the ALTER, and MariaDB said no: The reply from the server: Quick answer: the drop constraint MariaDB statement is ALTER TABLE t DROP CONSTRAINT name;, using the exact name from information_schema. Tested on MariaDB 13.0.2, Windows 11. I was one letter off. That’s ERROR 1091, and it … Read more >>