Running MySQL in Docker with prorm
Read this page in the documentation
Running MySQL in Docker with prorm Start the container Or use the repository's compose stack, which defines the same service: The --default-authentication-plugin=mysqlnativepassword flag matters: MySQL 8 defaults to cachingsha2password, which older client builds cannot negotiate. If your driver connects fine without it, drop it. Waiting for readiness MySQL is the slowest of the common engines to initialise, because the first start builds the data directory. Poll rather than sleep: Note that mysqladmin ping succeeds slightly before the MYSQLDATABASE is created on a first run. If you connect straight to ormtest and get "unknown database", wait for the database itself: Connect prorm to it A worked example Turn on strict mode MySQL's biggest footgun is silent coercion: without strict mode a too-long string is truncated and an invalid date becomes 0000-00-00, with no error. Set it per session: Session settings apply to one pooled connection, so set it in the pool's connection-init hook rather than once at startup — see SQL constants. Data persistence The compose service mounts tmpfs at /var/lib/mysql, so data is discarded on teardown and startup is much faster. Use a named volume if you need it to survive. Tear down Troubleshooting Symptom | Cause | --- | --- | ERNOTSUPPORTEDAUTHMODE | The client cannot do cachingsha2password. Start with --default-authentication-plugin=mysqlnativepassword. | Unknown database 'ormtest' | Connected during initialisation. Poll for the database, not just for mysqladmin ping. | Access denied for user | Env vars apply only on first start; an existing volume keeps the old credentials. | Values silently truncated | Strict mode is off. See above. | Too many connections | The default maxconnections is 151. Lower prorm's pool size or raise the server limit. | Related reading MySQL dialect SQL constants Connection pooling