Databases
Manage MySQL and MariaDB databases with our comprehensive guides and tutorials.
19 articles in this category
Creating a Database
Create MySQL databases and database users for your applications.
Using phpMyAdmin
Manage your databases through the phpMyAdmin web interface.
Database Backup & Import
Export and import database backups safely.
Remote Database Access
Connect to your database from external applications.
Character set, collation and the emoji trap
Arabic that saves as question marks and an emoji that truncates a whole field are the same fault: utf8 in MySQL is not UTF-8.
Error establishing a database connection
Four causes that produce the same sentence. Test the credentials directly and you know which one you have in thirty seconds.
The one index that matters
An index is a sorted lookup, not magic. Which column to index, why order matters in a composite one, and why more is not better.
Exporting without locking the site
A plain mysqldump locks your tables for the length of the dump. On a busy shop that is a visible outage, and one flag prevents it.
innodb_buffer_pool_size
The single most important MySQL setting. Too small and every query reads the disk; too large and the machine swaps.
Importing a large database dump
It times out, or fills the disk, or takes six hours. Three settings and one command make it minutes.
Moving a database to another server
Dump, transfer, import, and then the three things a dump does not carry: users, grants and the character set on the connection.
Database users and grants, without over-granting
One user per site, with only the rights that site needs. What to grant, what never to grant, and how to check what you already gave away.
MySQL or MariaDB, in practice
They started as the same database and have drifted. For most sites either is fine - here is where the difference actually shows.
Remote database access, safely
Opening port 3306 to the internet is how databases are found and drained. There is a way to connect remotely that exposes nothing.
Repairing a damaged table
Marked as crashed and should be repaired is a MyISAM message with a one-line fix. The same words on InnoDB mean something much more serious.
Replication in plain terms
A second copy of the database, kept up to date automatically. What it is good for, what it is not, and the lag that surprises people.
Finding the query that is slow
Turn on the slow log, read what it names, and add the one index that usually fixes it.
Copying a database to staging safely
A copy of live data on a test site is a copy of your customers. What to strip, what to rewrite, and how to do it in one pass.
MySQL: too many connections
The limit was reached, which is a symptom. Find what is holding connections open before raising anything.