Connect to any Lando service via Shell alias

Connect to any Lando service via Shell alias

Short shell alias function to open any database SQL client from the CLI when using Lando for local development.

Roman Zipp, April 24th, 2023

When using Lando as local development tooling, you will be familiar that localhost ports get assigned randomly. This can be tricky if you need to connect to a container regurarily.

This is a short shell function which builds a MySQL/MariaDB connection URI string using the lando and jq binaries.

Install jq

JQ is a lightweight and flexible command-line JSON processor made by Stephen Dolan which is used to extract details form the lando info JSON output.

macOS

brew install jq

Ubuntu

sudo apt-get install jq

Windows

See official install guide.

Shell function

Of course, you can alter the function to output any combination of connection details.

This example always uses the database lando service.

Shell function

Of course, you can alter the function to output any combination of connection details.

This example always uses the database lando service.