I'm working on standing up a CI environment on Shippable. I'm at a point where I have a test database and I need to run my migrations against it, but I get an error that makes no sense to me
The build step being executed is this:
(cd www && NODE_ENV=test knex --knexfile ./config/knexplus.js migrate:latest)
The output is this:
Working directory changed to ~/src/github.com/org/api/www/config
Using environment: test
Knex:warning - Pool2 - Error: Pool was destroyed
Knex:Error Pool2 - Error: ER_DBACCESS_DENIED_ERROR: Access denied for user ''@'localhost' to database 'my_test'
Knex:Error Pool2 - Error: ER_DBACCESS_DENIED_ERROR: Access denied for user ''@'localhost' to database 'my_test'
Error: Pool was destroyed
Don't get me wrong, I understand the message, but not why I receive it. Before running the migrations, I have the build dumping the knexplus.js
file content:
(cd www && cat ./config/knexplus.js)
'use strict';
exports.vagrant = exports.staging = exports.production = {
client: 'mysql',
connection: {
host: '127.0.0.1',
port: '3306',
user: 'shippable',
password: '',
database: 'mine',
timezone: 'UTC',
charset: 'utf8',
debug: false
},
migrations: {
tableName: '_migrations',
directory: '../db/migrations'
},
seeds: {
directory: '../db/seeds'
}
};
exports.test = {
client: 'mysql',
connection: {
host: '127.0.0.1',
port: '3306',
user: 'shippable',
password: '',
database: 'my_test',
timezone: 'UTC',
charset: 'utf8',
debug: false
},
migrations: {
tableName: '_migrations',
directory: '../db/migrations'
},
seeds: {
directory: '../db/seeds'
}
};
What I notice is that the error message seems to indicate that we're grabbing the right configuration since it's referencing the my_test
database, but the username and host are wrong.
Any idea what I might be missing here?
I ended up entering a support ticket and got this response:
The databases in the new default images don't have a "shippable" user, so MySQL notices that someone is trying to connect as a user that doesn't exist and tries to see if you can connect without a username. You can either create a shippable user by adding
mysql -e "GRANT ALL ON *.* TO shippable@localhost IDENTIFIED BY ''; FLUSH PRIVILEGES;"
to yourshippable.yml
in theci
section before connecting or connect as the root user.
All of the documentation I was reading at the time had the shippable
user. The first step is finding the right documentation, I guess.