我正在遵循Getting started section for the MySQL package on the Vapor Documentation,我可以逐步遵循它,因此,我已经使用以下自定义数据库凭据成功建立了与MySQL数据库的连接:>
/// Register providers first
try services.register(FluentMySQLProvider())
// MySQL database
let mySQLConfig = MySQLDatabaseConfig(hostname: "localhost",
port: 3306,
username: "root",
password: "thisismyrootpassword",
database: "lol_database",
capabilities: .default,
characterSet: MySQLCharacterSet.utf8_general_ci,
transport: MySQLTransportConfig.cleartext)
services.register(mySQLConfig)
Based on the MySQLDatabaseConfig
object's documentation我无法确定是否可以基于Unix套接字配置连接到MySQL数据库。
在生产环境下,我将能够为应用程序提供的只是数据库名称,用户名,密码和套接字路径,其格式为/cloudsql/project1:us-central1:instance1
要获得更多参考,我想做的就是根据此教程将Google Cloud App Engine灵活的环境连接到SQL数据库:https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql#setting_up_your_local_environment当然,环境仍然是蒸气,这是唯一的方法数据库客户端建立与数据库服务器的连接。
谢谢您的帮助。