How to Install the BigQuery CLI

Galaxy Glossary

How do I install the BigQuery CLI on macOS, Windows, or Linux?

The BigQuery CLI (bq) is a command-line tool for managing datasets, running queries, and administering Google BigQuery projects.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Description

Table of Contents

What does the BigQuery CLI do?

The bq CLI lets you create datasets, load data, and run SQL queries from any terminal. It supports scripting, automation, and CI/CD workflows.

What are the prerequisites?

Install Python 3.8+, have a Google Cloud account with BigQuery API enabled, and ensure you can run admin commands (sudo or elevated PowerShell).

How do I install on macOS with Homebrew?

Run brew install --cask google-cloud-sdk, then gcloud components install bq. Homebrew handles path updates automatically.

How do I install on Windows?

Use the MSI installer from Google Cloud or run choco install gcloudsdk in an elevated PowerShell, then execute gcloud components install bq.

How do I install on Debian/Ubuntu?

Add Google’s repo, update apt, then run sudo apt-get install google-cloud-cli. Finish with gcloud components install bq.

How do I install on RHEL/CentOS/Fedora?

Add the YUM repo, sudo dnf install google-cloud-cli, and enable bq with gcloud components install bq.

How do I verify the installation?

Run bq version. A proper install returns the CLI version and the underlying Python version.

How do I authenticate?

Execute gcloud auth login, select your Google account, then set a default project via gcloud config set project my-project-id.

How do I run a test query?

Run bq query --use_legacy_sql=false "SELECT COUNT(*) AS customers FROM `my_project.ecommerce.Customers`;" to confirm connectivity.

What are best practices?

Pin versions in CI images, use service-account JSON keys for automation, and add --format=json for script-friendly output.

What errors should I avoid?

Always run gcloud components update before debugging, and ensure the BigQuery API is enabled in the Cloud Console.

Where can I find more help?

Use bq help for command reference or visit the Google Cloud docs for advanced examples.

Why How to Install the BigQuery CLI is important

How to Install the BigQuery CLI Example Usage


bq query --use_legacy_sql=false "SELECT id, name, stock FROM `my_project.ecommerce.Products` WHERE stock < 5 ORDER BY stock;"

How to Install the BigQuery CLI Syntax


Install via gcloud:
  gcloud components install bq [--quiet]

Homebrew (macOS):
  brew install --cask google-cloud-sdk
  gcloud components install bq

Chocolatey (Windows):
  choco install gcloudsdk
  gcloud components install bq

APT (Debian/Ubuntu):
  echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
  sudo apt-get update && sudo apt-get install google-cloud-cli
  gcloud components install bq

Example query with ecommerce tables:
  bq query --use_legacy_sql=false \
    'SELECT c.id, c.name, SUM(oi.quantity) AS items_purchased\n     FROM `my_project.ecommerce.Customers` c\n     JOIN `my_project.ecommerce.Orders`  o  ON o.customer_id = c.id\n     JOIN `my_project.ecommerce.OrderItems` oi ON oi.order_id   = o.id\n     GROUP BY c.id, c.name\n     ORDER BY items_purchased DESC\n     LIMIT 10;'

Common Mistakes

Frequently Asked Questions (FAQs)

Can I install bq without the full Google Cloud SDK?

No. The bq component is distributed as part of the Cloud SDK. You must install the SDK, then add bq.

Does bq support service-account authentication?

Yes. Run gcloud auth activate-service-account --key-file=key.json and set the project to use non-interactive automation.

How do I upgrade bq?

Run gcloud components update. Homebrew, Chocolatey, and package manager installs fetch a newer SDK, then update bq automatically.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.