Reputation: 1529
I'm following the Getting started section for the MySQL package on the Vapor Documentation, which I'm able to follow step by step and, as a result, I have successfully established a connection to the MySQL database, using custom database credentials like this:
/// 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 I'm unable to find if it is possible to connect to a MySQL database based on a Unix Socket configuration.
What I'll be able to provide to the application under the production environment it's just the database name, the username, password and the Socket path, which will be in the form /cloudsql/project1:us-central1:instance1
For more reference, what I'm trying to do is connect from a Google Cloud App Engine flexible environment to a SQL database based on this tutorial: https://cloud.google.com/appengine/docs/flexible/nodejs/using-cloud-sql#setting_up_your_local_environment The environment of course will be Vapor still that's the only way for a database client to establish connection to the database server.
Thank you for your help.
Upvotes: 21
Views: 344
Reputation: 14666
Times have changed and there's now a unixDomainSocketPath
that can be used instead of hostname
/port
.
Upvotes: 2