简体   繁体   English

将Android应用程序连接到Google Cloud

[英]Connecting android app to google cloud

iam currently working on an android app that stores some user data in some mysql table in a database.Iam planning to host a server in google cloud but i dont even know where to start from,like how to create a database and sql table in mysql,how to connect my android app to the created mysql table in cloud. IAM目前正在开发一个Android应用,该应用将一些用户数据存储在数据库的某些mysql表中。Iam计划在Google Cloud中托管服务器,但我什至不知道从哪里开始,例如如何在mysql中创建数据库和sql表,如何将我的android应用连接到云中创建的mysql表。 Any help would be appreciable.I know this is a silly question,but please do help... i dont have any background codes running for my application,it only has a single sql table and 任何帮助都将是可贵的。我知道这是一个愚蠢的问题,但是请提供帮助...我没有为我的应用程序运行任何背景代码,它只有一个sql表,并且
the users insert and retrieve data to and from the table. 用户在表中插入数据或从中检索数据。

There is a example for mobile app and backend for google cloud. 有一个针对Google Cloud的移动应用和后端的示例。

Mobile app-backend-tutorial 行动应用程式后端教学课程

If you want to start with google cloud infrastructure, and connecting an android app to it, you can check thoses links: 如果您要开始使用Google Cloud Infrastructure,并连接一个android应用,则可以检查以下链接:

Hope that will help you 希望对您有帮助

First you should create a Cloud Sql instance and give it a name. 首先,您应该创建一个Cloud Sql实例并为其命名。 Clous Sql gives you an IP address. Clous Sql为您提供IP地址。 Then you can either import your database from inside google cloud sql or use MySql Workbench and the given ip to connect to your Cloud sql and import your db using workbench: 然后,您可以从Google Cloud sql内部导入数据库,也可以使用MySql Workbench和给定的ip连接到Cloud sql并使用Workbench导入数据库:

1. From Cloud Sql: 1.从Cloud Sql:

First you need to create a bucket and give it a name. 首先,您需要创建一个存储桶并为其命名。 Then upload your db into the bucket. 然后将您的数据库上传到存储桶中。 Cloud Sql can't import db directly from other directories. Cloud Sql无法直接从其他目录导入数据库。 then from Cloud sql -> import enter address of your database inside your bucket. 然后从Cloud sql-> import在存储桶中输入数据库的地址。

ex: gs://myBucket/mydb.sql 例如: gs://myBucket/mydb.sql

Note: don't forget to put USE XXX (XXX name of your db) inside mydb.sql so that Cloud Sql knows which databse you are talking about. 注意:不要忘记在db.sql中放入USE XXX (数据库的XXX名称),以便Cloud Sql知道您在谈论哪个数据库。

2. Import using Workbench: 2.使用工作台导入:

  • Go to Cloud Sql -> Access Control -> Authorization and add the IP address of your computer that you want to use to connect to the Cloud Sql. 转到Cloud Sql->访问控制->授权,然后添加要用于连接到Cloud Sql的计算机的IP地址。 Cloud Sql does not allow connections from unknown sources.(Security) Cloud Sql不允许来自未知来源的连接。(安全性)

  • Then from Cloud Sql -> Access Control -> Users you should add your database user name and password (root is default). 然后从Cloud Sql-> Access Control-> Users,您应该添加数据库用户名和密码(默认为root)。

  • You can check your Cloud Sql Ip address from Cloud Sql -> Access Control -> IP Address 您可以从Cloud Sql-> Access Control-> IP Address检查您的Cloud Sql Ip地址

  • Open MySql Workbench and create a new connection. 打开MySql Workbench并创建一个新的连接。 Enter IP address of your Cloud Sql and user name and password for your database and click test connection. 输入Cloud Sql的IP地址以及数据库的用户名和密码,然后单击测试连接。 Congratulations! 恭喜你! now you are connected to Cloud Sql. 现在您已连接到Cloud Sql。

  • Now you can create a new database or import an existing db as usual. 现在,您可以照常创建新数据库或导入现有数据库。

  • Then go back to Cloud Sql -> Databases and check your imported database. 然后回到Cloud Sql-> Databases并检查您导入的数据库。

I hope this helps. 我希望这有帮助。

I can recommend the udacity course on "Google App Engine": 我可以在“ Google App Engine”上推荐udacity课程:

https://www.udacity.com/course/ud859 https://www.udacity.com/course/ud859

It was a great time investment for me! 对我来说,这是一次很棒的投资!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM