【问题标题】:FluentMySQL connection using Unix SocketFluentMySQL 使用 Unix Socket 连接
【发布时间】:2019-02-04 21:16:58
【问题描述】:

我正在关注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 Socket 配置的 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 环境当然是 Vapor,但这是唯一的方法数据库客户端建立与数据库服务器的连接。

感谢您的帮助。

【问题讨论】:

标签: mysql swift vapor


【解决方案1】:

Times have changed 现在可以使用unix​Domain​Socket​Path 代替hostname/port

【讨论】:

    猜你喜欢
    • 2021-02-20
    • 1970-01-01
    • 2014-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多