论坛

云SQL.'Hello Wo...
 
Notifications
清除所有

云SQL.'Hello World' Tutorial


帖子:84
主持人
Topic starter
(@太极)
成员
Joined: 1 year ago

概述

在本教程中,您将:

  1. 实例化一个新的mysql实例

  2. 设置和查询数据库

  3. 清理实例

 

 

10分钟

项目设置

谷歌云平台资源被组织到项目中。云SQL需要一个 项目开始。

 Select a project, or 

创建SQL实例

你 can create a MySQL instance using the UI.

  1. 导航到SQL实例页面

    SQL.

     

  2. 点击 

  3. 选择数据库引擎:

    核实  被选中并单击   按钮。

  4. 选择MySQL实例类型:

    点击 

  5. 配置实例:

    默认配置应该足够。记住这些值, 你'LL以后引用:

    •  或选择 

  6. 点击 

 

连接到SQL实例

 GCLOUD. CLI用于与实例接口。这个工具来了 预先安装在Web控制台shell中。

单击打开云shell   在控制台右上角的导航栏中按钮。

使用此命令连接到实例:

gclous sql connect instanceIdeile \ --user = root
 
你 should see a prompt similar to the following:
mysql [(无)]
 

使用SQL实例

Within themysql.prompt, run the following:

  1. 创建数据库和表

    sql CREATE DATABASE geography; USE geography; CREATE TABLE cities (city VARCHAR(255), country VARCHAR(255));

  2. 插入数据

    sql INSERT INTO cities (city, country) values ("San Francisco", "USA"); INSERT INTO cities (city, country) values ("Beijing", "China");

  3. 询问

    sql SELECT * FROM cities;

    你 should see the following query results:

    选择*来自城市; + -------------- + --------- + + -------------- + ------ --- + + -------------- + --------- +
     

清理

你'LL需要清理新创建的资源。

  1. 导航到SQL实例页面。

    SQL.
  2. 点击一下  链接转到详细信息页面。

  3. 点击 

 

 
主题标签
1 回复
帖子:84
主持人
Topic starter
(@太极)
成员
Joined: 1 year ago
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> sql CREATE DATABASE geography; USE geography; CREATE TABLE cities (city VARCHAR(255), country VARCHAR(255));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sql CREATE DATABASE geography' at line 1
ERROR 1049 (42000): Unknown database 'geography'
ERROR 1046 (3D000): No database selected
mysql>  CREATE DATABASE geography; USE geography; CREATE TABLE cities (city VARCHAR(255), country VARCHAR(255));
Query OK, 1 row affected (0.03 sec)

Database changed
Query OK, 0 rows affected (0.05 sec)

mysql> INSERT INTO cities (city, country) values ("San Francisco", "USA"); INSERT INTO cities (city, country) values ("Beijing", "China");
Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.04 sec)

mysql> SELECT * FROM cities;
+---------------+---------+
| city          | country |
+---------------+---------+
| San Francisco | USA     |
| Beijing       | China   |
+---------------+---------+
2 rows in set (0.03 sec)

mysql>
mysql>  CREATE DATABASE geography; USE geography; CREATE TABLE cities (city VARCHAR(255), country VARCHAR(255));
Query OK, 1 row affected (0.03 sec)

Database changed
Query OK, 0 rows affected (0.05 sec)

mysql> INSERT INTO cities (city, country) values ("San Francisco", "USA"); INSERT INTO cities (city, country) values ("Beijing", "China");
Query OK, 1 row affected (0.04 sec)

Query OK, 1 row affected (0.04 sec)

mysql> SELECT * FROM cities;
+---------------+---------+
| city          | country |
+---------------+---------+
| San Francisco | USA     |
| Beijing       | China   |
+---------------+---------+
2 rows in set (0.03 sec)

mysql>


回复
分享: