如何在Ubuntu 18.04上连接到托管数据库

介绍 (Introduction)

Managed databases have a number of benefits over self-managed databases, including automated updates, simplified scaling, and high availability. If you’re new to working with managed databases, though, the best way to perform certain tasks — like connecting to the database — may not be self-evident.

托管数据库相对于自我管理数据库具有许多优点,包括自动更新,简化的扩展和高可用性。 但是,如果您不熟悉托管数据库,那么执行某些任务(例如连接到数据库)的最佳方法可能并不简单。

In this guide, we will go over how to install client programs for a variety of database management systems (DBMSs), including PostgreSQL, MySQL, and Redis, on an Ubuntu 18.04 server. We’ll also explain how to use these programs to connect to a managed database instance.

在本指南中,我们将介绍如何在Ubuntu 18.04服务器上为各种数据库管理系统(DBMS)安装客户端程序,包括PostgreSQLMySQLRedis 。 我们还将说明如何使用这些程序连接到托管数据库实例。

Note: The instructions outlined in this guide were tested with DigitalOcean Managed Databases, but they should generally work for managed databases from any cloud provider. If, however, you run into issues connecting to a database provisioned from another provider, you should consult their documentation for help.

注意:本指南中概述的说明已通过DigitalOcean托管数据库进行了测试,但它们通常应适用于任何云提供商的托管数据库。 但是,如果在连接到其他提供者提供的数据库时遇到问题,则应查阅其文档以获取帮助。

先决条件 (Prerequisites)

To follow the instructions detailed in this guide, you will need:

要遵循本指南中详述的说明,您将需要:

Once you have these in place, jump to whichever section aligns with your DBMS.

一旦安装好这些位置,请跳至与DBMS对齐的任何部分。

连接到托管的PostgreSQL数据库 (Connecting to a Managed PostgreSQL Database)

To connect to a managed PostgreSQL database, you can use psql, the standard command line client for Postgres. It’s open-source, maintained by the PostgreSQL Development Group, and is usually included when you download the PostgreSQL server. However, you can install psql by itself by installing the postgresql-client package with APT.

要连接到托管的PostgreSQL数据库,可以使用psql (Postgres的标准命令行客户端)。 它是开源的,由PostgreSQL开发组维护,通常在下载PostgreSQL服务器时包括在内。 但是,您可以通过使用APT安装postgresql-client软件包来单独安装psql

If you’ve not done so recently, update your server’s package index:

如果您最近没有这样做,请更新服务器的软件包索引:

  • sudo apt update

    sudo apt更新

Then run the following command to install psql:

然后运行以下命令来安装psql

  • sudo apt install postgresql-client

    sudo apt安装postgresql客户端

APT will ask you to confirm that you want to install the package. Do so by pressing ENTER.

APT将要求您确认要安装该软件包。 按下ENTER

Following that, you can connect to your managed Postgres database without any need for further configuration. For example, you might invoke psql with the following flags:

之后,您可以连接到托管的Postgres数据库,而无需进一步配置。 例如,您可以使用以下标志调用psql

  • -U, the PostgreSQL user you want to connect as

    -U ,您要连接的PostgreSQL用户

  • -h, the managed database’s hostname or IP address

    -h ,托管数据库的主机名或IP地址

  • -p, the TCP port on which the managed database is listening for connections

    -p ,托管数据库正在侦听连接的TCP端口

  • -d, the specific database you want to connect to

    -d ,您要连接的特定数据库

  • -v, short for “variable,” precedes other connection variables, followed by an equal sign (=) and the variables’ values. For example, if you want to validate the database’s CA certificate when you connect, you would include -v sslmode=require in your command

    -v是“变量”的缩写,在其他连接变量之前,后跟等号( = )和变量的值。 例如,如果要在连接时验证数据库的CA证书,则可以在命令中包含-v sslmode=require

  • -W, which tells psql to prompt you for the PostgreSQL user’s password. Note that you could precede the psql command with PGPASSWORD=password, but it’s generally considered more secure to not include passwords on the command line

    -W ,它告诉psql提示您输入PostgreSQL用户的密码。 请注意,可以在psql命令之前使用PGPASSWORD= password ,但是通常认为在命令行中不包含密码会更安全。

With these flags included, the psql command’s syntax would look like this:

包括这些标志后, psql命令的语法将如下所示:

  • psql -U user -h host -p port -d database -v variable=value -W

    psql -U 用户 -h 主机 -p 端口 -d 数据库 -v 变量 = 值 -W

Alternatively, if your managed database provider offers a uniform resource identifer (URI) for connecting, you might use the following syntax:

或者,如果您的托管数据库提供程序提供了用于连接的统一资源标识符 (URI),则可以使用以下语法:

  • psql postgresql://username:password@host:port/database?option_1=value&option_n=value

    psql postgresql:// 用户名 : 密码 @ 主机 : 端口 / 数据库 ? option_1 = 值 & option_n = 值

Note: If you’re connecting to a DigitalOcean Managed Database, you can find all of this connection information in your Cloud Control Panel. Click on Databases in the left-hand sidebar menu, then click on the database you want to connect to and scroll down to find its Connection Details section. From there, you do one of the following:

注意:如果要连接到DigitalOcean托管数据库,则可以在Cloud Control Panel中找到所有这些连接信息。 点击数据库在左侧边栏菜单,然后单击要连接到和向下滚动找到它的连接细节部分的数据库。 从那里开始,执行以下操作之一:

  • Select the Connection parameters option and copy the relevant fields individually into the psql syntax detailed previously

    选择“ 连接参数”选项,并将相关字段分别复制到前面详细介绍的psql语法中

  • Select the Connection String option and copy a ready-made connection URI you can paste into the connection URI syntax outlined above

    选择“ 连接字符串”选项并复制一个现成的连接URI,您可以将其粘贴到上面概述的连接URI语法中

  • Select the Flags option and copy a ready-to-use psql command that you can paste into your terminal to make the connection

    选择标志选项,然后复制一个可以使用的psql命令,您可以将其粘贴到终端中以进行连接

With that, you’re ready to begin using with your managed PostgreSQL instance. For more information on how to interact with PostgreSQL, see our guide on How to Manage an SQL Database. You may also find our Introduction to Queries in PostgreSQL useful.

这样,您就可以开始使用托管的PostgreSQL实例了。 有关如何与PostgreSQL交互的更多信息,请参见《 如何管理SQL数据库》指南 。 您可能还会发现我们的PostgreSQL查询简介非常有用。

连接到托管MySQL数据库 (Connecting to a Managed MySQL Database)

To access a managed MySQL database, you will need to install a MySQL client on the machine from which you plan to make the connection. It’s possible to connect using the mysql command, as provided by the MySQL Command-Line Client, but this command doesn’t support connection strings. For greater flexibility with how you connect, we recommend that you instead use the mysqlsh command which allows you to use the official MySQL Shell, as it gives you the freedom to connect with either flags or a connection URI.

要访问托管MySQL数据库,您将需要在计划建立连接的计算机上安装MySQL客户端。 可以使用MySQL命令行客户端提供的mysql命令进行连接,但是此命令不支持连接字符串。 为了更大程度地提高连接方式的灵活性,建议您改用mysqlsh命令,该命令允许您使用官方的MySQL Shell ,因为它使您可以自由地使用标志或连接URI进行连接。

In order to access a DigitalOcean Managed MySQL database, you will need to install version 8.0 or above of the MySQL shell. To do so, you must first add the MySQL software repository before installing the mysql-shell package.

为了访问DigitalOcean托管MySQL数据库,您将需要安装8.0或更高版本MySQL Shell。 为此,必须首先添加MySQL软件存储库,然后再安装mysql-shell软件包。

Begin by navigating to the MySQL APT Repository page in your web browser. Find the Download button in the lower-right corner and click through to the next page. This page will prompt you to log in or sign up for an Oracle web account. You can skip that and instead look for the link that says No thanks, just start my download. Right-click the link and select Copy Link Address (this option may be worded differently, depending on your browser).

首先,在Web浏览器中导航至MySQL APT存储库”页面 。 在右下角找到“ 下载”按钮,然后单击进入下一页。 该页面将提示您登录或注册Oracle Web帐户。 您可以跳过该链接,而是寻找显示“ 不,谢谢”的链接,只需开始下载即可 。 右键单击链接,然后选择“ 复制链接地址” (此选项的措词可能有所不同,具体取决于您的浏览器)。

Now you’re ready to download the file. On your server, move to a directory you can write to:

现在您可以下载文件了。 在服务器上,移至您可以写入的目录:

  • cd /tmp

    cd / tmp

Download the file using curl, remembering to paste the address you just copied in place of the highlighted portion of the following command. You also need to pass two command line flags to curl. -O instructs curl to output to a file instead of standard output. The L flag makes curl follow HTTP redirects, which is necessary in this case because the address you copied actually redirects to another location before the file downloads:

使用curl下载文件,记住记住将刚复制的地址粘贴到以下命令的突出显示部分。 您还需要传递两个命令行标志以进行curl-O指示curl输出到文件而不是标准输出。 L标志使curl遵循HTTP重定向,在这种情况下这是必需的,因为您复制的地址实际上在文件下载之前重定向到另一个位置:

  • curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

    curl -OL https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb

The file should now be downloaded in your current directory. List the files to make sure:

现在应将文件下载到当前目录中。 列出文件以确保:

  • ls

    ls

You will see the filename listed in the output:

您将在输出中看到列出的文件名:


   
   
Output
mysql-apt-config_0.8.15-1_all.deb . . .

Now you can add the MySQL APT repository to your system’s repository list. The dpkg command is used to install, remove, and inspect .deb software packages. The following command includes the -i flag, indicating that you’d like to install from the specified file:

现在,您可以将MySQL APT存储库添加到系统的存储库列表中。 dpkg命令用于安装,删除和检查.deb软件包。 以下命令包含-i标志,指示您要从指定的文件安装:

  • sudo dpkg -i mysql-apt-config*

    须藤dpkg -i mysql-apt-config *

During the installation, you’ll be presented with a configuration screen where you can specify which version of MySQL you’d prefer, along with an option to install repositories for other MySQL-related tools. The defaults will add the repository information for the latest stable version of MySQL and nothing else. This is what we want, so use the down arrow to navigate to the Ok menu option and hit ENTER.

在安装过程中,将为您提供一个配置屏幕,您可以在其中指定所需MySQL版本,并可以选择安装其他MySQL相关工具的存储库。 默认值将添加最新稳定版本MySQL的存储库信息,仅此而已。 这就是我们想要的,因此请使用向下箭头导航至“ Ok菜单选项,然后按ENTER

Following that, the package will finish adding the repository. Refresh your apt package cache to make the new software packages available:

之后,软件包将完成添加存储库。 刷新您的apt软件包缓存以使新软件包可用:

  • sudo apt update

    sudo apt更新

Next, you can clean up your system a bit and delete the file you downloaded, as you won’t need it in the future:

接下来,您可以稍微清理一下系统并删除下载的文件,因为以后将不再需要它:

  • rm mysql-apt-config*

    rm mysql-apt-config *

Note: If you ever need to update the configuration of these repositories, run the following command to select your new options:

注意:如果需要更新这些存储库的配置,请运行以下命令以选择新选项:

  • sudo dpkg-reconfigure mysql-apt-config

    须藤dpkg重新配置mysql-apt-config

After selecting your new options, run the following command to refresh your package cache:

选择新选项后,运行以下命令以刷新程序包缓存:

  • sudo apt update

    sudo apt更新

Now that you’ve added the MySQL repositories, you’re ready to install the actual MySQL Shell software. Do so with the following apt command:

现在,您已经添加了MySQL存储库,现在可以安装实际MySQL Shell软件了。 使用以下apt命令执行此操作:

  • sudo apt install mysql-shell

    sudo apt安装mysql-shell

Once that command finishes, check the software version number to ensure that you have the latest release:

该命令完成后,请检查软件版本号以确保您具有最新版本:

  • mysqlsh --version

    mysqlsh --version

   
   
Output
mysqlsh Ver 8.0.19 for Linux on x86_64 - for MySQL 8.0.19 (MySQL Community Server (GPL))

After you’ve installed the mysql-shell package, you can access your managed database by running the mysqlsh command with the following flags as arguments:

安装mysql-shell软件包后,可以通过运行mysqlsh命令并使用以下标志作为参数来访问托管数据库:

  • -u, the MySQL user you want to connect as

    -u ,您要连接MySQL用户

  • -p, tells mysqlsh to prompt for the user’s password. You could include your password directly in the connection command following the -p flag (without a space, as in -ppassword) but, for security reasons, this is generally not recommended

    -p ,告诉mysqlsh提示输入用户密码。 您可以直接在-p标志后面的连接命令中包含密码(不带空格,如-p password ),但是出于安全原因,通常不建议这样做

  • -h, the database’s hostname or IP address

    -h ,数据库的主机名或IP地址

  • -P, the TCP port on which MySQL is listening for connections

    -P ,MySQL正在侦听连接的TCP端口

  • -D, the specific database you want to connect to

    -D ,您要连接的特定数据库

Additionally, you may want to include the --sql option. When the MySQL Shell opens a new session, it does so in one of three modes: SQL, JavaScript, or Python. The SQL mode opens a session in which you can use SQL to query and manipulate data, as well as create databases, tables, groups, or anything else you need to store and manage your data. The JavaScript and Python modes allow you to use functions available in those respective languages to create a number session objects. This lets you employ multiple MySQL server instances from the same MySQL Shell instance.

此外,您可能要包括--sql选项。 当MySQL Shell打开新会话时,它将以以下三种模式之一进行操作:SQL,JavaScript或Python。 SQL模式打开一个会话,您可以在其中使用SQL查询和操作数据,以及创建数据库,表,组或其他任何需要存储和管理数据的内容。 JavaScript和Python模式允许您使用这些相应语言可用的函数来创建数字会话对象。 这使您可以从同一MySQL Shell实例中使用多个MySQL服务器实例。

MySQL shell will open sessions in the JavaScript mode by default. Thus, if you want to run SQL queries as one would typically do with the MySQL command line client, you’ll need to specify the --sql option to establish a connection in the SQL mode.

默认情况下,MySQL Shell将以JavaScript模式打开会话。 因此,如果要像通常使用MySQL命令行客户端那样运行SQL查询,则需要指定--sql选项以SQL模式建立连接。

Using these flags, the mysqlsh syntax will look like this:

使用这些标志, mysqlsh语法将如下所示:

  • mysqlsh -u user -p -h host -P port -D database --sql

    mysqlsh -u 用户 -p -h 主机 -P 端口 -D 数据库 --sql

Alternatively, if you have a connection URI you can use to connect, you would use a syntax like this:

另外,如果您具有可用于连接的连接URI,则可以使用如下语法:

  • mysqlsh --sql mysql://user:password@host:port/database?option_1=value&option_n=value

    mysqlsh --sql mysql:// 用户 : 密码 @ 主机 : 端口 / 数据库 ? option_1 = 值 & option_n = 值

Note: If you’re connecting to a DigitalOcean Managed Database, you can find all of this connection information in your Cloud Control Panel. Click on Databases in the left-hand sidebar menu, then click on the database you want to connect to and scroll down to find its Connection Details section. From there, you do one of the following:

注意:如果要连接到DigitalOcean托管数据库,则可以在Cloud Control Panel中找到所有这些连接信息。 点击数据库在左侧边栏菜单,然后单击要连接到和向下滚动找到它的连接细节部分的数据库。 从那里开始,执行以下操作之一:

  • Select the Connection parameters option and copy the relevant fields individually into the mysqlsh syntax outlined previously

    选择连接参数选项,并将相关字段分别复制到前面概述的mysqlsh语法中

  • Select the Connection String option and copy a ready-made connection URI you can paste into the connection string command detailed above

    选择“ 连接字符串”选项并复制一个现成的连接URI,您可以将其粘贴到上面详细介绍的连接字符串命令中

With that, you’re ready to begin using your managed MySQL instance.

这样,您就可以开始使用托管MySQL实例了。

If you’re new to working with the MySQL Shell, one thing to note is that, in order to close the connection, the exit command used in other MySQL clients won’t work. Instead, you’ll need to run the \q shortcut:

如果您不熟悉MySQL Shell,则需要注意的一件事是,为了关闭连接,其他MySQL客户端中使用的exit命令将不起作用。 相反,您需要运行\q快捷方式:

  • \q

    \ q

   
   
Output
Bye!

For more information on how to interact with MySQL, see our guide on How to Manage an SQL Database. You may also find our Introduction to Queries in MySQL useful.

有关如何与MySQL进行交互的更多信息,请参见有关如何管理SQL数据库的指南 。 您可能还会发现我们的MySQL查询简介非常有用。

关于MySQL 8中密码验证的注意事项 (A Note Regarding Password Authentication in MySQL 8)

In MySQL 8.0 and newer, the default authentication plugin is caching_sha2_password. As of this writing, though, PHP does not support caching_sha2_password. If you plan on using your managed MySQL database with an application that uses PHP, such as WordPress or phpMyAdmin, this may lead to issues when the application attempts to connect to the database.

在MySQL 8.0和更高版本中,默认身份验证插件为caching_sha2_password 。 但是,在撰写本文时,PHP不支持caching_sha2_password 。 如果计划将托管MySQL数据库与使用PHP的应用程序(例如WordPress或phpMyAdmin)一起使用,则当应用程序尝试连接到数据库时,这可能会导致问题。

If you have access to the database’s configuration file, you could add a setting to force it to use a PHP-supported authentication plugin — for example, mysql_native_password — by default:

如果您有权访问数据库的配置文件,则可以添加一个设置以强制其使用默认情况下使用PHP支持的身份验证插件—例如, mysql_native_password

Example MySQL Configuration File
示例MySQL配置文件
[mysqld]
default-authentication-plugin=mysql_native_password

However, some managed database providers — including DigitalOcean — do not make the database configuration file available to end users. In this case, you could connect to the database and run an ALTER USER command for any existing MySQL users which need to connect to the database, but can’t do so with the caching_sha2_password plugin:

但是,某些托管数据库提供程序(包括DigitalOcean)不会使数据库配置文件可供最终用户使用。 在这种情况下,您可以连接到数据库并为需要连接到数据库的任何现有MySQL用户运行ALTER USER命令,但是使用caching_sha2_password插件无法这样做:

  • ALTER USER user IDENTIFIED WITH mysql_native_password BY 'password';

    使用“ 密码 ”通过mysql_native_password更改ALTER USER 用户的身份;

Of course, you can set new users to authenticate with mysql_native_password by specifying the plugin in their respective CREATE USER statements:

当然,您可以通过在各自的CREATE USER语句中指定插件来设置新用户使用mysql_native_password进行身份验证:

  • CREATE USER user IDENTIFIED WITH mysql_native_password BY 'password';

    使用mysql_native_password通过' password '创建用户用户名

If you’re using a DigitalOcean Managed Database, be aware that if you configure a user to authenticate with a plugin other than caching_sha2_password then you won’t be able to see that user’s password in your Cloud Control Panel. For this reason, you should make sure you note down the passwords of any users that authenticate with mysql_native_password or other plugins in a secure location.

如果您使用的是DigitalOcean托管数据库,请注意,如果您将用户配置为使用caching_sha2_password以外的插件进行身份验证,则您将无法在Cloud Control Panel中看到该用户的密码。 因此,应确保在安全的位置记下所有使用mysql_native_password或其他插件进行身份验证的用户的密码。

连接到托管Redis数据库 (Connecting to a Managed Redis Database)

When you install Redis locally, it comes with redis-cli, the Redis command line interface. You can use redis-cli to connect to a remote, managed Redis instance, but it doesn’t natively support TLS/SSL connections. There are ways you can configure redis-cli to securely connect to a managed Redis instance (for example, by configuring a TLS tunnel, but there are alternative Redis clients that have built-in TLS support.

在本地安装Redis时,它会带有redis-cli (Redis命令行界面)。 您可以使用redis-cli连接到远程托管的Redis实例,但它本身不支持TLS / SSL连接。 您可以通过多种方式配置redis-cli以安全地连接到托管Redis实例(例如,通过配置TLS隧道) ,但是还有其他具有内置TLS支持的Redis客户端。

For DigitalOcean Managed Redis Databases, we recommend that you install Redli, an open-source, interactive Redis terminal. To do so, navigate to the Releases Page on the Redli GitHub project and locate the Assets table for the latest release. As of this writing, this will be version 0.4.4.

对于DigitalOcean托管Redis数据库,我们建议您安装Redli,这是一个开放源代码的交互式Redis终端。 为此,请导航至Redli GitHub项目上的Releases页面 ,并找到最新发行版的Assets表。 在撰写本文时,它将是0.4.4版。

There, find the link for the file ending in linux_amd64.tar.gz. This link points to an archive file known as a tarball that, when extracted, will create a few files on your system. Right-click this link and select Copy link address (this option may differ depending on your web browser).

linux_amd64.tar.gz找到以linux_amd64.tar.gz结尾的文件的链接。 该链接指向一个称为tarball的存档文件,该存档文件在解压缩后将在系统上创建一些文件。 右键单击此链接,然后选择“ 复制链接地址” (此选项可能会因Web浏览器而异)。

On your server, move to a directory you can write to:

在服务器上,移至您可以写入以下目录:

  • cd /tmp

    cd / tmp

Then, paste the link into the following wget command, replacing the highlighted URL. This command will download the file to your server:

然后,将链接粘贴到以下wget命令中,替换突出显示的URL。 此命令会将文件下载到您的服务器:

  • wget https://github.com/IBM-Cloud/redli/releases/download/v0.4.4/redli_0.4.4_linux_amd64.tar.gz

    wget https://github.com/IBM-Cloud/redli/releases/download/v0.4.4/redli_0.4.4_linux_amd64.tar.gz

Once the file has been downloaded to your server, extract the tarball:

将文件下载到服务器后,解压缩tarball:

  • tar xvf redli_0.4.4_linux_amd64.tar.gz

    tar xvf redli_ 0.4.4 _linux_amd64.tar.gz

This will create the following files on your server:

这将在您的服务器上创建以下文件:


   
   
Output
LICENSE.txt README.md redli

The redli file is the Redli binary file. Move it to the /usr/local/bin directory, the location where Ubuntu looks for executable files:

redli文件是Redli 二进制文件 。 将其移动到/usr/local/bin目录,Ubuntu在该目录中查找可执行文件:

sudo mv redli /usr/local/bin/

At this point, you can clean up your system a bit and remove the tarball:

此时,您可以稍微清理一下系统并删除压缩包:

  • rm redli_0.4.4_linux_amd64.tar.gz

    rm redli_ 0.4.4 _linux_amd64.tar.gz

Now you can use Redli to connect to your managed Redis instance. You could do so by running the redli command followed by these flags:

现在,您可以使用Redli连接到托管Redis实例。 您可以通过运行redli命令以及以下标志来做到这一点:

  • -h, the host to connect to. This can either be a hostname or an IP address

    -h ,要连接的主机。 这可以是主机名或IP地址

  • -a, the password used to authenticate to the Redis instance

    -a ,用于对Redis实例进行身份验证的密码

  • -p, the port to connect to

    -p ,连接到的端口

With these flags included, the redli syntax would be as follows. Note that this example also includes the --tls option, which allows you to connect to a managed Redis database over TLS/SSL without the need for a tunnel:

包括这些标志后, redli语法将如下所示。 请注意,此示例还包括--tls选项,该选项使您无需隧道即可通过TLS / SSL连接到托管Redis数据库:

  • redli --tls -h host -a password -p port

    redli --tls -h 主机 -a 密码 -p 端口

One benefit that Redli has over redis-cli is that it understands the rediss protocol, which is used to designate a URI pointing to a Redis database. This allows you to use a connection string to access your database:

Redli与redis-cli相比的一个好处是它了解rediss协议,该协议用于指定指向Redis数据库的URI。 这使您可以使用连接字符串来访问数据库:

  • redli --tls -u rediss://user:password@host:port

    redli --tls -u rediss:// 用户 : 密码 @ 主机 : 端口

Note that this example includes the -u flag, which specifies that the following argument will be a connection URI.

请注意,此示例包括-u标志,该标志指定以下参数将是连接URI。

Note: If you’re connecting to a DigitalOcean Managed Database, you can find all of this connection information in your Cloud Control Panel. Click on Databases in the left-hand sidebar menu, then click on the database you want to connect to and scroll down to find the Connection Details section. From there, you do one of the following:

注意:如果要连接到DigitalOcean托管数据库,则可以在Cloud Control Panel中找到所有这些连接信息。 点击数据库在左侧边栏菜单,然后单击要连接到和向下滚动找到连接详细信息部分中的数据库上。 从那里开始,执行以下操作之一:

  • Select the Connection parameters option and copy the relevant fields individually into the redli syntax detailed previously

    选择连接参数选项,然后将相关字段分别复制到前面详细介绍的redli语法中

  • Select the Connection String option and copy a ready-made connection URI that you can use with the connection string syntax outlined above

    选择“ 连接字符串”选项,然后复制可与上述连接字符串语法一起使用的现成的连接URI。

  • Select the Flags option and copy a ready-to-use redli command that you can paste into your terminal to make the connection

    选择标志选项,然后复制可使用的redli命令,您可以将其粘贴到终端中以进行连接

Following that, you can begin interacting with your managed Redis instance. For more information on how to work with Redis, see our series or cheat sheets on How To Manage a Redis Database.

之后,您可以开始与托管Redis实例进行交互。 有关如何使用Redis的更多信息,请参阅有关如何管理Redis数据库的系列或备忘单。

结论 (Conclusion)

As a relatively new development in cloud services, many practices that are well known for self-managed databases aren’t widely or comprehensively documented for databases managed by cloud providers. One of the most fundamental of these practices, accessing the database, may not be immediately clear to those new to working with managed databases. Our goal for this tutorial is that it helps get you started as you begin using a managed database for storing data.

作为云服务的一个相对较新的发展,对于自托管数据库众所周知的许多实践尚未广泛或全面地记录在云提供商管理的数据库中。 对于那些刚开始使用托管数据库的人来说,访问数据库可能是这些实践中最基本的方法之一。 本教程的目标是帮助您开始使用托管数据库存储数据时入门。

For more information on working with databases, we encourage you to check out our variety of database-related content, including tutorials focused directly on PostgreSQL, MySQL, and Redis.

有关使用数据库的更多信息,建议您查看我们与数据库相关的各种内容 ,包括直接针对PostgreSQLMySQLRedis的教程。

To learn more about DigitalOcean Managed Databases, please see our Managed Databases product documentation.

要了解有关DigitalOcean托管数据库的更多信息,请参阅我们的托管数据库产品文档

翻译自: https://www.digitalocean.com/community/tutorials/how-to-connect-to-managed-database-ubuntu-18-04

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值