Move to Lerd from Valet, Herd, DBngin or a MySQL installed with your package manager, data included. One command copies a site's database from the server on your machine into Lerd's own.
Your sites link to Lerd in a minute, but their data is still in the MySQL, MariaDB or PostgreSQL server you were using before. This plugin copies it into Lerd's own database service, one site at a time or all at once, and only ever reads the server it copies from.
lerd plugin install db-import-hostSee what is on the machine's server and which Lerd site each database fills, then import:
lerd db-import-host:list
cd ~/code/shop
lerd db-import-host:importlerd db-import-host:import shop blog imports named sites and --all every site whose database exists on the machine's server. It is also in the site's Commands menu in the dashboard as Import database from this machine, and AI assistants get db-import-host_list and db-import-host_import through Lerd's MCP server. The full instructions are on the plugin's Documentation tab in the dashboard.
| Option | Meaning |
|---|---|
--all |
Import every site whose database exists on the machine's server |
--from |
The database on the machine's server, when its name differs from the site's |
--database |
The site's database in Lerd, when Lerd does not know it (WordPress, Drupal) |
By default it connects to 127.0.0.1:3306 as root with no password for MySQL and MariaDB, and 127.0.0.1:5432 as postgres for PostgreSQL. To save anything else, run lerd db-import-host:connect and answer its questions; it tries the connection before saving. Or pass it all at once:
lerd db-import-host:connect mysql --user root --password secret
lerd db-import-host:connect mysql --socket /run/mysqld/mysqld.sock
lerd db-import-host:connect postgres --port 5433 --bin-dir /Applications/Postgres.app/Contents/Versions/latest/bin- Dumps the database with the machine's own
mysqldump/mariadb-dumporpg_dump, skipping Lerd's shims of the same name, which run inside Lerd's containers and cannot reach the machine's server. - Creates the site's Lerd database if needed and takes a
before-host-importsnapshot, solerd db:restoreundoes the import. - Replaces what Lerd held for that database with the dump.
- Swaps a MariaDB dump's
utf8mb4_uca1400_*collations andNO_AUTO_CREATE_USERsql mode for what MySQL accepts when the site uses Lerd's MySQL. - Imports a database shared by several sites in a group only once with
--all.
It reads the databases you import from the server on this machine, and never writes to that server. It reads the site list from Lerd's API. It replaces the site's Lerd database, after the snapshot. The dump is written to tmp/ in the plugin's data folder and deleted once imported. The connection you save with connect, password included, is kept in connection.json in the same folder, readable only by you. Nothing leaves your machine.
- Lerd 1.38 or newer, and Node, which Lerd installs
- The client tools of the server you import from, on your
PATHor found through--bin-dir
node --test test/
lerd plugin install .MIT
