2 · Local database
Objective — confirm the local DB provisioned in Phase 2 is running, uses utf8mb4, and is the database .env points Laravel at. Create it only if it is missing (for a local-only workflow or a skipped Phase 2), then prove the installer can connect.
Steps at a glance:
- Start the database service — In Herd → Services → Database, start
Local_MySQLorLocal_MariaDB(wait for the green dot). - Verify the connection — Herd Pro requires a TCP connection (
-h 127.0.0.1), not a socket. - Confirm or create the database — Phase 2 Step 1 should already have created it; this step verifies charset/collation and creates only if missing.
- Confirm
.envpoints at it and prove the connection — Phase 2 Step 5 activated local.env; this step confirms Laravel resolves the right DB and table count.
Background
Section titled “Background”The installer needs a reachable local database before page 4 runs. Phase 2 owns the provisioning and .env template activation; this page is the local readiness checkpoint that catches a stopped DB service, wrong charset, stale config cache, or .env pointing at the wrong schema.
Use Zaj-PROJECT.md as the non-secret source for the local DB row: DB engine/version, host/port, database name, username, charset/collation, and last verified date. Do not put passwords there; keep secret values in the vault.
1. Start the database service
Section titled “1. Start the database service”In Herd → Services → Database, start Local_MySQL or Local_MariaDB (wait for the green dot). Homebrew (brew services start mysql / mariadb), DBngin, and MAMP all work too.
-
Start the service and wait for its green dot — or use a terminal alternative.
Terminal window brew services start mysql # or: brew services start mariadb# Expected: "Successfully started" (skip if you started it from the Herd GUI)- ✅ The local DB engine is running.
2. Verify the connection
Section titled “2. Verify the connection”Herd Pro requires a TCP connection (-h 127.0.0.1), not a socket.
-
Connect over TCP and print the engine version.
Terminal window mysql -h 127.0.0.1 -P 3306 -u root -e "SELECT VERSION();"# Expected: a single version string (e.g. 11.x-MariaDB or 8.x)- ✅ A version prints — no socket error.
-
If it fails, map the error to its fix.
Error Fix Can't connect through socket '/tmp/mysql.sock'Add -h 127.0.0.1 -P 3306Connection refusedStart the DB service from Herd Access deniedCheck the root password in Herd’s DB settings - ✅ Reconnecting after the fix returns a version.
3. Confirm or create the database
Section titled “3. Confirm or create the database”Phase 2 Step 1 should already have created the local database and user. Run the idempotent create anyway: it is a no-op when the DB exists, and it only creates the schema if Phase 2 was skipped or you are doing a local-only workflow.
-
Confirm the
utf8mb4database exists, creating it only if missing.Terminal window mysql -h 127.0.0.1 -u root -e "CREATE DATABASE IF NOT EXISTS \`[project]_local_db\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"# Expected: no output (silent success; no-op if Phase 2 already created it)- ✅ The database exists; no error printed. If Phase 2 already created it, this command changed nothing.
-
Verify the charset and collation.
Terminal window mysql -h 127.0.0.1 -u root -N -e "SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME='[project]_local_db';"# Expected: utf8mb4 utf8mb4_unicode_ci- ✅ The local DB is charset-safe for the installer.
Use the exact local DB name from Phase 2 if your project used a different suffix. utf8mb4 matters — many CodeCanyon apps store emoji and multi-byte content and throw collation errors on a 3-byte utf8 database.
4. Confirm .env points at it and prove the connection
Section titled “4. Confirm .env points at it and prove the connection”Phase 2 Step 5 laid down and activated the local .env. Confirm the live file resolves to the provisioned local DB, then prove Laravel can use it.
-
Confirm the
DB_*block in.env.DB_CONNECTION=mysqlDB_HOST=127.0.0.1DB_PORT=3306DB_DATABASE=[project]_local_dbDB_USERNAME=[project]_local_userDB_PASSWORD=""- ✅
.envpoints at the Phase 2 local DB.rootwith an empty password is the simplest local example, but a dedicated per-env user/password from Phase 2 is valid and preferred.
- ✅
-
Clear the stale config cache, then check the connection.
Terminal window php artisan config:clearphp artisan db:show 2>&1 | head -5# Expected: connection details for [project]_local_db; 0 tables for fresh install, or the existing table count when resuming- ✅
db:showreports the right database.
- ✅
-
If
db:showlooks wrong, confirm with a direct query — it can report tables from a different project on the same server.Terminal window DB_NAME=$(grep '^DB_DATABASE=' .env | cut -d= -f2 | tr -d '"')mysql -h 127.0.0.1 -u root -N -e "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='${DB_NAME}';"# Expected: 0 tables (fresh install) — OR the existing table count if the installer already ran (resuming)- ✅ The direct query returns the correct table count for this project state.
One more reason to trust the direct query over the artisan helper:
Checklist
Section titled “Checklist”Do not mark this step done until every box below is checked.
- 👤 DB service running — green dot in Herd, or
brew services. - 🤖 Connects over TCP —
mysql -h 127.0.0.1connects without a socket error. - 🤖 Local schema confirmed — exists or was created only if missing, with
utf8mb4/utf8mb4_unicode_ci. - 🤖
.envverified —DB_*resolves to the Phase 2 local DB and every secret is double-quoted. - 🤖 Table count interpreted —
0for a fresh install, or an existing table count accepted with evidence when resuming. - 🤖 Project state updated —
Zaj-PROJECT.mdrecords the local DB engine/version, host/port, DB name, DB user, charset/collation, and verification date; passwords stay only in the vault.