本节描述了连接到部署在 OCI 计算实例上的 MySQL 服务器的各种连接方法。This section describes the various connection methods for connecting to the deployed MySQL server on the OCI Compute Instance.
本节提供了一些关于从类 UNIX 平台连接到 OCI 计算的详细信息。有关使用 SSH 连接的更多信息,请参见 使用 SSH 访问 Oracle Linux 实例 和 连接到您的实例。This section gives some detail on connecting from a UNIX-like platform to the OCI Compute. For more information on connecting with SSH, see Accessing an Oracle Linux Instance Using SSH and Connecting to Your Instance.
要使用 SSH 连接到在计算实例上运行的 Oracle Linux,请运行以下命令:To connect to the Oracle Linux running on the Compute Instance with SSH, run the following command:
ssh opc@computeIP其中 opc 是计算用户,computeIP 是您的计算实例的 IP 地址。where opc is the compute user and
computeIP is the IP address of your
Compute Instance.
要查找为 root 用户创建的临时 root 密码,请运行以下命令:To find the temporary root password created for the root user, run the following command:
sudo grep 'temporary password' /var/log/mysqld.log
要更改默认密码,请使用生成的临时密码登录服务器,使用以下命令:mysql -uroot -p。然后运行以下命令:To change your default password, log in to the server using the
generated, temporary password, using the following command:
mysql -uroot -p. Then run the following:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
要从本地 MySQL 客户端连接,必须首先在 MySQL 服务器上创建一个允许远程登录的用户。To connect from your local MySQL client, you must first create on the MySQL server a user which allows remote login.
要从本地 MySQL 客户端连接到 MySQL 服务器,请在 shell 会话中运行以下命令:To connect to the MySQL Server from your local MySQL client, run the following command from your shell session:
mysql -uroot -p -hcomputeIP其中 computeIP 是计算实例的 IP 地址。where computeIP is the IP address of
your Compute Instance.
要从本地 MySQL Shell 连接到 MySQL 服务器,请运行以下命令以启动 shell 会话:To connect to the MySQL Server from your local MySQL Shell, run the following command to start your shell session:
mysqlsh root@computeIP其中 computeIP 是计算实例的 IP 地址。where computeIP is the IP address of
your Compute Instance.
有关 MySQL Shell 连接的更多信息,请参见 MySQL Shell 连接。For more information on MySQL Shell connections, see MySQL Shell Connections.
要从 MySQL Workbench 连接到 MySQL 服务器,请参见 MySQL Workbench 中的连接。To connect to the MySQL Server from MySQL Workbench, see Connections in MySQL Workbench.