---
title: "Accessing your database from the command line"
date: "2024-02-14T06:18:38+00:00"
summary: "Learn how to access your Cloud Platform database using command-line tools or the API. Discover step-by-step instructions for using ah-sql-cli, ah-sql-connect, and database management options for developers and administrators."
image:
type: "page"
url: "/acquia-cloud-platform/accessing-your-database-command-line"
id: "bdc68d77-30b8-495d-bd3d-e7f62d4d898f"
---

Note

Custom Drush commands are not supported in Cloud Next environments.

You can access the databases of your Cloud Platform application by running the [ah-sql-cli](/node/56325#ah-sql-cli) command, or by using the [Cloud Platform API](#cloud-access-db-api). The [ah-sql-cli](/node/56325#ah-sql-cli) command is the same as running the `drush sql-cli` command, except [ah-sql-cli](/node/56325#ah-sql-cli) does not require a functioning Drupal website.

If you prefer to use a GUI, you can use [phpMyAdmin](https://www.phpmyadmin.net/), a GUI-based MySQL database management tool. For more information, see [Tools for administering your database](/acquia-cloud-platform/manage-apps/database/tools).

Accessing your database with ah-sql-cli
---------------------------------------

To access a database in your application using the [ah-sql-cli](/node/56325#ah-sql-cli) command:

1.  Connect to an environment of your application using SSH.
    
    For more information, see [Managing applications using the command line](/acquia-cloud-platform/manage-apps/command-line).
    
2.  Open a connection to your database with a command similar to the following:
    
        ah-sql-cli @[site].[env]
    
    Replace `[site]` with your application name and `[env]` with the name of the environment whose database you want to connect to (typically, `dev`, `test`, or `prod`, for the development, staging, and production environments, respectively). 
    
    Note
    
    *   Unlike `drush sql-cli`, the [ah-sql-cli](/node/56325#ah-sql-cli) command does not support the `--uri` option. For example:
        *   If your [sitename](/definitions/sitename) is `myexample` and you want to connect to the primary database for your production environment, use the following command:
            
                ah-sql-cli @myexample.prod
            
    *   In Cloud Next environments, you must use the `drush sql-cli` command instead of the [ah-sql-cli](/node/56325#ah-sql-cli) command.
    *   You can run SQL commands from the `mysql>` prompt. Enter `quit` to exit when you finish.
    

### Similar commands to ah-sql-cli

Cloud Platform also includes the [ah-sql-connect](/acquia-cloud-platform/manage-apps/command-line/drush/custom-commands#ah-sql-connect) command, which is a Drush command you can also use connect to your database. The [ah-sql-connect](/node/56325#ah-sql-connect) command is like `drush sql-connect`, except that [ah-sql-connect](/acquia-cloud-platform/manage-apps/command-line/drush/custom-commands#ah-sql-connect) doesn’t require a functioning Drupal website. The [ah-sql-connect](/node/56325#ah-sql-connect) command takes the same [options](#cloud-ahsqlcli-options) as [ah-sql-cli](/node/56325#ah-sql-cli). The output of [ah-sql-connect](/node/56325#ah-sql-connect) is the MySQL command (with user name, password, and database name) which you can use to connect to your database. For example:

    ah-sql-connect @[site].[env] mysql -h free-1712 -u example1dev -myverysecurepassword example1dev

### Command options

To review the arguments and options for the [ah-sql-cli](/node/56325#ah-sql-cli) and [ah-sql-connect](/node/56325#ah-sql-connect) Drush commands, see [Custom Drush commands for Cloud Platform](/acquia-cloud-platform/manage-apps/command-line/drush/custom-commands).

Accessing your database with the Cloud Platform API
---------------------------------------------------

With the [Cloud Platform API](/acquia-cloud-platform/develop-apps/api), you can create, restore, and delete backups of your application’s databases. For an example implementation, use the [example database creation script](/node/55797/#section-api-notification-examplephp).