Guides — 33 for MySQL

MySQL guides

Everything we've written about MySQL: connections, SQL patterns, imports, clients, and comparisons.

01Connect & How-To

Connect & How-To

Connect & How-ToMySQL

How to Connect to MySQL from Ruby

Connect to MySQL from Ruby with mysql2 or trilogy, plus Sequel and ActiveRecord. Working code for connections, pooling, parameterized queries, the utf8mb4 trap, and the caching_sha2_password authentication problem on MySQL 8.

6 min read
Connect & How-ToMySQL

How to Connect to MySQL from PHP

Connect to MySQL from PHP with PDO and mysqli: the utf8mb4 charset, real prepared statements, the EMULATE_PREPARES tradeoff, transactions, SSL, caching_sha2_password, and the errors you actually hit.

8 min read
Connect & How-ToMySQL

How to Connect to MySQL from C# (.NET)

Connect to MySQL from C# with MySqlConnector: ADO.NET basics, async commands, parameters, pooling, Dapper and EF Core, the MySql.Data vs MySqlConnector choice, SSL, and the errors you actually hit.

6 min read
Connect & How-ToMySQL

How to Connect to MySQL from Java

Connect to MySQL from Java with MySQL Connector/J: DriverManager, PreparedStatement, HikariCP pooling, SSL, time zones, and the errors you actually hit in production.

7 min read
Connect & How-ToMySQL

How to Connect to MySQL from Go

Connect to MySQL from Go with go-sql-driver/mysql and database/sql. Working code for connection pools, the DSN parseTime and loc traps, context timeouts, parameterized queries, and common authentication errors.

6 min read
Connect & How-ToMySQL

How to Connect to MySQL from Node.js

Connect to MySQL from Node.js with mysql2. Working code for pools, prepared statements, and async/await, the caching_sha2_password auth error explained, and why the legacy mysql package is no longer an option.

7 min read
Connect & How-ToMySQL

How to Connect to MySQL from Python

Connect to MySQL from Python with mysqlclient, PyMySQL, MySQL Connector/Python, or SQLAlchemy. Working code for connections, queries, pooling, and common errors.

7 min read
Connect & How-ToMySQL

Aggregate Functions in MySQL

How to use MySQL aggregate functions: COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING, GROUP_CONCAT, and GROUP BY WITH ROLLUP for multi-level summaries.

5 min read
Connect & How-ToMySQL

Common Table Expressions (CTEs) in MySQL

Learn how to use CTEs in MySQL 8.0+, including recursive CTEs for hierarchical data, multi-step queries, and version compatibility notes.

5 min read
Connect & How-ToMySQL

MySQL Date and Time Functions

A practical guide to MySQL date functions: DATE_FORMAT, DATEDIFF, DATE_ADD, DATE_SUB, STR_TO_DATE, NOW, CURDATE, TIMESTAMPDIFF, and timezone handling.

4 min read
Connect & How-ToMySQL

Full-Text Search in MySQL

How to use MySQL FULLTEXT indexes and MATCH AGAINST for natural language search, boolean mode, and query expansion, with relevance scoring and gotchas.

5 min read
Connect & How-ToMySQL

MySQL Indexes Explained

Understand MySQL index types (B-tree, FULLTEXT, spatial, covering indexes), how to create them, read EXPLAIN output, and avoid common pitfalls.

5 min read
Connect & How-ToMySQL

MySQL Joins: INNER, LEFT, RIGHT, CROSS, Self, and Anti-Joins

A complete guide to MySQL join types with examples: INNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN, self-joins, anti-joins, and join order optimization.

5 min read
Connect & How-ToMySQL

Working with JSON in MySQL

A practical guide to MySQL JSON functions: JSON_EXTRACT, ->, ->>, JSON_SET, JSON_TABLE, JSON_ARRAYAGG, and JSON_OBJECTAGG, with real query examples.

5 min read
Connect & How-ToMySQL

Pivot Tables in MySQL

How to pivot rows into columns in MySQL using CASE/GROUP BY for static pivots and dynamic SQL with prepared statements for runtime column generation.

4 min read
Connect & How-ToMySQL

MySQL String Functions

A practical reference for MySQL string functions: CONCAT, SUBSTRING, REPLACE, REGEXP_REPLACE, GROUP_CONCAT, TRIM, LENGTH, UPPER, LOWER, and more.

5 min read
Connect & How-ToMySQL

Window Functions in MySQL 8.0

Learn how to use MySQL window functions including ROW_NUMBER, RANK, DENSE_RANK, NTILE, LAG, and LEAD with the OVER and PARTITION BY clauses.

5 min read
02SQL How-To

SQL How-To

SQL How-ToMySQL

MySQL EXPLAIN and EXPLAIN ANALYZE: Reading Query Execution Plans

How to use MySQL EXPLAIN, EXPLAIN FORMAT=JSON, and EXPLAIN ANALYZE (8.0.18+) to understand query execution plans, identify slow spots, and optimize queries.

6 min read
SQL How-ToMySQL

MySQL Generated Columns: VIRTUAL vs STORED, Indexing, and Use Cases

How MySQL generated columns work -- the difference between VIRTUAL and STORED, when to index them, practical use cases for computed columns, and the limitations to know.

5 min read
SQL How-ToMySQL

MySQL Table Partitioning: RANGE, LIST, HASH, KEY, and Partition Pruning

How MySQL table partitioning works -- RANGE, LIST, HASH, and KEY partition types, partition pruning, and honest limitations before you commit to partitioning.

6 min read
SQL How-ToMySQL

MySQL Stored Procedures: CREATE PROCEDURE, Parameters, Cursors, and Error Handling

How to write MySQL stored procedures -- IN/OUT/INOUT parameters, local variables, cursors for row-by-row processing, and DECLARE HANDLER for error handling.

5 min read
SQL How-ToMySQL

Converting String Data to JSON in MySQL: JSON_OBJECT, JSON_ARRAY, and Migration Patterns

How to use MySQL's JSON_OBJECT and JSON_ARRAY functions to build JSON from relational data, convert legacy string-serialized columns to native JSON, and query the results.

5 min read
SQL How-ToMySQL

Subqueries in MySQL: Correlated, IN, EXISTS, and Derived Tables

A practical guide to MySQL subqueries -- correlated vs non-correlated, IN vs EXISTS, derived tables, and when to rewrite as a JOIN for better performance.

5 min read
SQL How-ToMySQL

MySQL Transactions: START TRANSACTION, SAVEPOINT, Isolation Levels, and InnoDB

A complete guide to MySQL transactions -- ACID properties, START TRANSACTION vs autocommit, SAVEPOINT, all four isolation levels, and how InnoDB implements locking.

6 min read
SQL How-ToMySQL

MySQL Triggers: BEFORE and AFTER INSERT, UPDATE, DELETE -- Use Cases and Pitfalls

How MySQL triggers work, how to write BEFORE and AFTER triggers for INSERT, UPDATE, and DELETE, practical use cases, and the performance and debugging pitfalls to know before using them.

5 min read
SQL How-ToMySQL

MySQL Upsert: INSERT ON DUPLICATE KEY UPDATE, REPLACE INTO, and INSERT IGNORE

How to handle insert-or-update logic in MySQL using INSERT ON DUPLICATE KEY UPDATE, REPLACE INTO, and INSERT IGNORE -- with honest tradeoffs for each approach.

5 min read
SQL How-ToMySQL

Views in MySQL: CREATE VIEW, Updatable Views, and Materialized View Patterns

How to create and manage MySQL views, when views are updatable, how WITH CHECK OPTION works, and how to simulate materialized views using tables and events.

5 min read
← All guides