Docs cipi.yml Web panel API MCP Ecosystem Guides Compare GitHub Telegram channel
  1. Home
  2. Guides
  3. Run Laravel on MySQL instead of MariaDB
Laravel

Run Laravel on MySQL instead of MariaDB

Replace MariaDB with MySQL 8.4 on port 3306 with one command, before the first app. What changes, what stays the same, what to check in your code, and how to move a server that already runs apps.

By Updated 6 min read

MariaDB is Cipi's default and fits most Laravel apps without friction. Some teams need MySQL itself: a vendor that only certifies MySQL, parity with a managed MySQL in another environment, or a team standard. Since Cipi 5.13 one command puts MySQL on port 3306 instead, on a server that has no databases yet.

MySQL instead of MariaDB
$ cipi db engines
$ cipi db switch mysql

Key ideas, in plain words#

TermMeaning
Port 3306Where Laravel's mysql driver connects. On a Cipi server it runs MariaDB or MySQL, never both
Engine mariadbCipi's name for "the server on port 3306". It keeps that name after a switch, so --engine=mariadb, cipi.yml, backups and the API don't change
SwitchMariaDB's packages removed, MySQL installed with the same root password and Cipi's tuning
Empty serverNo database, no app and nothing in Cipi's registry on port 3306. The only place a switch runs
MoveA server already in use moves its apps to a new, switched server with cipi sync

1. Decide: MySQL, MariaDB or PostgreSQL#

The two servers grew from the same code and speak the same protocol, so most Laravel apps can't tell them apart. The differences show up in edge features and in operations.

Stay on MariaDB ifSwitch to MySQL ifLook at PostgreSQL if
You have no specific reason to change: it's the default, tuned and tested on every Cipi serverA vendor, an auditor or a contract asks for MySQL by nameYou need JSONB, rich indexes (GIN, GiST, partial), pgvector or PostGIS
Your app uses RETURNING, sequences, or the native uuid / inet6 column typesAnother environment runs managed MySQL (RDS, Aurora MySQL, Laravel MySQL) and you want the same engine everywhereYou want one engine for the app, analytics and BI tools
You want features such as the thread pool in the free community server (MySQL keeps its thread pool for the Enterprise edition)Your team runs MySQL tooling (MySQL Shell, Percona Toolkit) and knows its behaviourYou're starting a new product and can choose freely (guide)

Differences that matter for a Laravel app#

TopicMariaDBMySQL 8.4What to do
json columnsAn alias of LONGTEXT with a json_valid() checkA binary JSON typeNothing for casts and where('meta->key', …): both work. See moving data
UUID and IP typesNative uuid and inet6 typesNot availableLaravel's uuid() on the mysql driver is char(36) on both. Only raw SQL or the mariadb driver uses the native types
INSERT … RETURNING, sequencesSupportedNot supportedSearch the code for raw RETURNING and NEXTVAL before moving
Default utf8mb4 collationUCA 14 (utf8mb4_uca1400_ai_ci)utf8mb4_0900_ai_ciLaravel's config/database.php sets utf8mb4_unicode_ci, which both have. Cipi maps the server defaults on restore
Default authenticationmysql_native_passwordcaching_sha2_passwordNothing: PHP's mysqlnd supports both
Queue SKIP LOCKEDYesYesThe database queue driver works on both

2. Start from a new server#

A switch never converts data, so it belongs at the very beginning of a server's life.

ChooseBecause
Ubuntu 26.04Its archive ships MySQL 8.4 LTS. On 24.04 you get 8.0, which Oracle stopped supporting on April 30, 2026; Ubuntu still publishes security updates for it, but a new server should start on the current LTS line
Cipi 5.13.1 or later5.13.0 could stop silently right after "Checking the MySQL packages…" (nothing was changed). sudo cipi self-update if in doubt
A fresh VPSSame sizing as for MariaDB: 2 GB of RAM is comfortable for a few apps. Cipi sizes MySQL's buffer pool from the RAM

Install Cipi as usual (VPS, SSH and DNS basics):

bash
wget -O - https://cipi.sh/setup.sh | bash

3. Switch before the first app#

Log in as the cipi user and look at what runs on port 3306:

bash
sudo cipi db engines
sudo cipi db switch mysql

The command asks before it touches anything, then goes through these steps:

Step 1 of 6Checks

Cipi verifies that the server has no databases on port 3306, that apt offers a mysql-server package, and — with a simulation — that removing MariaDB would remove nothing but its own packages and client libraries (a Perl driver or a monitoring agent that depends on them stops the switch). It also waits if a dump, such as a backup, is running.

In a provisioning script there is no terminal to confirm on, so the switch refuses to run without --yes:

bash
wget -O - https://cipi.sh/setup.sh | SSH_PUBKEY="ssh-ed25519 AAAA… ops" bash
cipi db switch mysql --yes

The switch is refused, on purpose, on a server that already has a database, an app or a registry entry on port 3306. The message lists what it found. Don't delete apps to get past it: use step 6.

4. Check the result#

bash
sudo cipi db engines           # "Port 3306 runs MySQL (engine id: mariadb)"
sudo cipi db engines --json    # "server": "mysql" for the engine "mariadb"
mysql --version
sudo cat /etc/mysql/mysql.conf.d/99-cipi.cnf
WhereYou should see
cipi db enginesmariadb installed 3306 *, then Port 3306 runs MySQL
cipi service listThe MySQL unit, watched by the monitor
Web panelMySQL on the server's databases tab
/var/lib/mysql.mariadb-<time>The old (empty) MariaDB data directory. Remove it once you're happy: sudo rm -rf /var/lib/mysql.mariadb-*

5. Create apps as usual#

Nothing in the app workflow changes. The default engine is still mariadb, which now means MySQL:

bash
sudo cipi app create --user=shop --domain=shop.example.com \
    --repository=git@github.com:acme/shop.git --branch=main --php=8.5
ThingValue on a MySQL server
.envDB_CONNECTION=mysql, DB_HOST=127.0.0.1, DB_PORT=3306, its own user and password
TablePlus / DBeaver URLmysql+ssh://… (printed at creation and by cipi credentials)
cipi.yml databasesengine: mariadb, or leave it out
Backups, cipi db backup/restore, cipi db passwordSame commands; the MySQL client does the work
Patchingcipi db upgrade and the nightly autoupdate follow MySQL's packages
PortLocalhost only. Connect over SSH; never open 3306 to the internet

Run the test suite against MySQL in CI too, so you find engine differences before production does:

yaml
# .github/workflows/tests.yml (excerpt)
services:
  mysql:
    image: mysql:8.4
    env: { MYSQL_DATABASE: testing, MYSQL_ROOT_PASSWORD: secret }
    ports: ["3306:3306"]
    options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
# then run the tests with DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_DATABASE=testing DB_USERNAME=root DB_PASSWORD=secret

6. Move a server that already runs apps#

The data is never converted in place: a dump can't carry everything (MariaDB's uuid/inet6 types, sequences, SQL only one server understands), and what it drops would surface later, in your apps. So a server in use moves the way any app moves on Cipi: to a new server.

Step 1 of 6Test in CI

Run the test suite against MySQL (the workflow above) and fix what fails. Search for raw RETURNING, NEXTVAL, uuid/inet6 columns and MariaDB-only functions.

bash
# new server
sudo cipi db switch mysql
sudo cipi php install 8.4
sudo cipi sync trust                    # paste the key from the old server
# old server
sudo cipi sync pubkey
sudo cipi sync push --host=203.0.113.20 --with-db --with-storage --import
# new server, after DNS points to it
sudo cipi ssl install shop

What happens to the dumps on the way in#

In the dumpRestored into MySQL as
MariaDB's sandbox line (/*M!999999\- enable the sandbox mode */), which the MySQL client refusesDropped
UCA 14 collations (utf8mb4_uca1400_*)The matching MySQL 0900 collations
Rows of dataUntouched

The same filter works in the other direction: a MySQL dump restored into MariaDB gets its 0900 collations mapped to UCA 14. It applies to cipi db restore, cipi sync and restores from backups.

JSON columns after the move#

A column created as json on MariaDB is a LONGTEXT with a check, and a dump carries it that way: on MySQL it stays a text column. Laravel's json/array casts and JSON where clauses keep working. If you want MySQL's binary JSON type, convert the column in a migration after the move, on a quiet moment and with a fresh backup:

php
Schema::table('orders', function (Blueprint $table) {
    $table->json('meta')->nullable()->change();
});

7. The way back#

SituationHow
Switched, no database created yetsudo cipi db switch mariadb: same checks, same steps, the other way round
Apps already on MySQLMove them to a MariaDB server with cipi sync, as in step 6
Moved from an old server last weekPoint DNS back at the old server you kept. Data written since the move has to be copied back

Troubleshooting#

MessageFix
MariaDB → MySQL runs only on a server with no databases on port 3306The server is in use. Move the apps to a new, switched server (step 6)
Replacing the database server is never implicitNo terminal to confirm on: add --yes
No mysql-server package available from aptRun sudo apt-get update and check apt-cache policy mysql-server: a source list is missing or broken. Nothing was changed
Removing MariaDB would also remove: …Another package depends on MariaDB's client libraries. Remove it first, or stay on MariaDB. Nothing was changed
A database dump is runningA backup is in progress. Try again when sudo cipi backup status shows it finished
Stops after "Checking the MySQL packages…" with no messageCipi 5.13.0: sudo cipi self-update to 5.13.1 or later and run it again
cipi db install mysql doesn't switchBy design: install never replaces a server. Use cipi db switch mysql
App says Access denied after a movesudo cipi db password <app> sets a new password in the database and .env together

Questions

Can I switch a server that already has apps?

Not in place. cipi db switch only runs on a server with no databases on port 3306, because there is no safe in-place conversion between the two. Use a new server, switch it before the first app, then move the apps with cipi sync (step 6).

Do I need to change `DB_CONNECTION`?

No. Laravel's mysql driver talks to both servers, and Cipi writes DB_CONNECTION=mysql on MariaDB and on MySQL alike.

Which MySQL version do I get?

The one in the Ubuntu archive: 8.4 LTS on Ubuntu 26.04, 8.0 on 24.04. Prefer 26.04 for a new MySQL server: Oracle ended support for 8.0 on April 30, 2026.

Can MariaDB and MySQL run side by side?

No. Port 3306 runs one of them. PostgreSQL can run next to either (cipi db install pgsql).

Why is the engine still called `mariadb`?

So nothing that stores or exchanges it changes shape: apps.json, cipi.yml, backups and the API keep the same id. It means "the server on port 3306", whichever it is.

Can I do it from the web panel or the API?

No. Replacing a database server is an operator decision, so it stays on the command line. The panel shows MySQL where it runs.

How do I go back?

On a server with no databases: sudo cipi db switch mariadb. On a server in use: the old server you moved from is your way back, which is why you keep it for a while.

Try it on your own server

Free and open source. One command on a fresh Ubuntu 24.04 or 26.04 VPS.

wget -O - https://cipi.sh/setup.sh | bash
Read the quickstart