Reputation: 1197
I am using Knex.js for database connections. I would like to use a connection string instead of the connection object for connecting to a database and be able to specify the charset
.
Example:
connection: 'mysql://root:[email protected]:3306/test-db'
NOT
connection: {
host : '127.0.0.1',
user : 'root',
password : 'secret',
database : 'test-db',
charset : 'utf8'
}
I have the connection string working.
Could someone explain how I would specify the charset
in the Knex.js connection string?
Upvotes: 12
Views: 6839
Reputation: 3710
Try:
connection: 'mysql://root:[email protected]:3306/test-db?charset=utf8mb4'
See connection string options as described here: https://github.com/mysqljs/mysql#connection-options
Upvotes: 6