Managing relational databases such as PostgreSQL, MySQL, and SQLite directly from a remote server or local developer environment often requires switching between clunky graphical interfaces and bare command-line clients. While standard interactive shells like psql and mysql are powerful, navigating tables, inspecting foreign key relationships, and running test queries without auto-completion can slow down routine workflows. Lazysql is a modern, lightweight terminal user interface (TUI) for SQL databases written in Go that provides keyboard-driven database navigation, real-time query editing, and structured schema browsing directly inside the terminal window.
Because lazysql operates as a single compiled binary without heavy background dependencies or Electron frameworks, it executes instantly across Ubuntu, Debian, Fedora, Arch Linux, and Alpine systems. In this guide, you will learn how to install lazysql on Linux, configure secure database connections, navigate tables and schemas using intuitive keyboard shortcuts, and execute ad-hoc SQL queries with instant tabular visualisations.
What Is Lazysql and Why Use It in the Linux Terminal?
Inspired by terminal productivity tools like Lazygit and Lazydocker, lazysql brings structured convenience to database administration in headless or remote server setups. Rather than memorising verbose metadata commands like \dt+ or running repetitive DESCRIBE queries, lazysql splits your terminal workspace into dedicated visual panels for connections, tables, records, and SQL queries.
- Multi-Engine Support: Connect seamlessly to PostgreSQL, MySQL, MariaDB, and SQLite databases using standard unified connection strings.
- Resource Efficiency: Consumes mere megabytes of RAM compared to GUI clients like DBeaver, DataGrip, or pgAdmin, making it ideal for resource-constrained virtual private servers (VPS).
- Vim-Style Navigation: Move effortlessly between tree views, tables, and editing panes using familiar
h,j,k, andlnavigation keys. - Inline Query Editor: Write custom SQL statements with syntax highlighting, execute them with a single keystroke, and inspect paginated results immediately.
Installing Lazysql on Linux
Lazysql offers multiple installation pathways depending on your preferred package manager and Linux distribution.
Method 1: Installing via Pre-Compiled GitHub Binary
The fastest way to install lazysql across any distribution is to download the latest static release directly from GitHub releases:
- Open your terminal and determine the latest release architecture (typically
Linux_x86_64orLinux_arm64). - Download the archive using
curl:curl -LO https://github.com/jorgerojas26/lazysql/releases/latest/download/lazysql_Linux_x86_64.tar.gz - Extract the binary archive:
tar -xzf lazysql_Linux_x86_64.tar.gz - Move the executable to your system path:
sudo mv lazysql /usr/local/bin/ - Verify the installation:
lazysql --version
Method 2: Installing via Go
If you have Go installed on your Linux workstation (version 1.21 or later), you can compile and install lazysql directly:
go install github.com/jorgerojas26/lazysql@latest
Ensure that your ~/go/bin directory is present in your shell $PATH variable.
Method 3: Installing via Homebrew on Linux
If you use Linuxbrew, install lazysql with a single command:
brew install jorgerojas26/lazysql/lazysql
Connecting to Databases in Lazysql
Lazysql allows you to launch interactive sessions either by specifying a connection string directly on the command line or by configuring persistent connection profiles inside its built-in manager.
Launching with Direct Connection Strings
To connect immediately without configuring a saved profile, pass the target database URL as a command argument:
- PostgreSQL:
lazysql "postgres://dbuser:password@localhost:5432/production_db?sslmode=disable" - MySQL / MariaDB:
lazysql "mysql://dbuser:password@tcp(localhost:3306)/app_database" - SQLite:
lazysql "sqlite3:///var/lib/sqlite/application.db"
Using the Interactive Connection Manager
If you launch lazysql without arguments by simply typing lazysql, the tool presents an interactive connection management dialogue:
- Press
cto create a new connection profile. - Select your database driver (PostgreSQL, MySQL, or SQLite) using the arrow keys.
- Enter connection metadata including Host, Port, Database Name, Username, and Password.
- Press
Ctrl+Sor select Save to store the profile in your user configuration file located at~/.config/lazysql/config.yaml. - Highlight the saved connection and press
Enterto establish the session.
Navigating Databases and Executing Queries
Once connected, lazysql organises your terminal window into functional side-by-side split panels.
Essential Keyboard Navigation Shortcuts
| Key Combination | Context / Action |
|---|---|
Tab / Shift+Tab |
Cycle focus forward and backward between panels (Tree, Table Records, SQL Editor). |
h, j, k, l or Arrow Keys |
Navigate rows, columns, and tree structures. |
Enter |
Expand selected database schemas or load table records into the main view. |
/ |
Search or filter records in the active table view. |
Ctrl+E |
Toggle and focus the embedded SQL query editor. |
Ctrl+R |
Execute the active SQL query in the editor pane. |
q / Ctrl+C |
Close dialogs or quit lazysql. |
Executing Custom Queries and Inspecting Data
- In the active connection view, press
Tabto navigate to the database tree on the left. - Highlight any table and press
Enterto load the first batch of rows into the central grid. - Press
Ctrl+Eto enter the query editor panel. - Type your query, such as
SELECT id, username, email FROM users WHERE active = true ORDER BY created_at DESC LIMIT 50;. - Press
Ctrl+Rto run the query. The result set displays below the editor with column widths automatically formatted to fit your terminal dimensions.
Practical Best Practices for Remote Database Administration
To maximise efficiency and security when managing Linux databases with lazysql, keep the following workflow habits in mind:
- Tunnel Connections via SSH: When querying remote production databases, avoid opening public database ports. Instead, establish an SSH tunnel with
ssh -L 5433:localhost:5432 [email protected]and point lazysql tolocalhost:5433. - Protect Configuration Files: Ensure your connection profiles containing credentials are secure by restricting permissions on the configuration directory with
chmod 600 ~/.config/lazysql/config.yaml. - Integrate with Terminal Multiplexers: Run lazysql inside a dedicated tmux or zellij pane alongside your application logs and server metrics for a comprehensive terminal operations dashboard.