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.

Connect to any Lando service via Shell alias
24 Apr 2023
|
2 min read

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

1brew install jq

Ubuntu

1sudo 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.

1Shell function
2
3Of course, you can alter the function to output any combination of connection details.
4
5This example always uses the database lando service.


Read more...