2

I have a bunch of TDD code, including database tests and I've tried to upload to Github. I've just checked on my local machine, every test are passed. enter image description here

Also I'm trying to use Travis CI to check my tests are succeed or failed. My job log shows,

mysql -u root -e 'CREATE DATABASE worldCountries;'

mysql -u root -e "CREATE USER 'user45'@'localhost' IDENTIFIED BY 'user45';"

ERROR 1396 (HY000) at line 1: Operation CREATE USER failed for 'user45'@'localhost'

The command "mysql -u root -e "CREATE USER 'user45'@'localhost' IDENTIFIED BY 'user45';"" failed and exited with 1 during .

I have found a really similar question, but it didn't help me to solve the issue.

My travis.yml file is the following:

language: php
php:
  - '5.6'
  - '7.0'
  - hhvm
services:
  - mysql
dist: trusty
sudo: required
addons:
  apt:
  packages:
  - mysql-server-5.6
  - mysql-client-core-5.6
  - mysql-client-5.6
before_script:
  - mysql -u root -e 'CREATE DATABASE worldCountries;'
  - mysql -u root -e "CREATE USER 'user45'@'localhost' IDENTIFIED BY 'user45';"
  - mysql -u root -e "GRANT ALL ON worldCountries.* TO 'user45'@'localhost';"
  - composer self-update
  - composer install --prefer-source --no-interaction
script:
  - vendor/bin/phpunit
  - vendor/bin/phpmd src/ text phpmd.xml

I appreciate every answer!

-- Edit --

On my local machine, the mysql service works perfectly. All of my test passed green, and the database tests works fine.

With the same settings (as below travis.yml) I've tried to synchronize my repository in Travis, and I've received the failed report.

Community
  • 1
  • 1
Bálint Pap
  • 498
  • 2
  • 12
  • 23
  • 1
    Same error code based question -> https://stackoverflow.com/questions/5555328/error-1396-hy000-operation-create-user-failed-for-jacklocalhost – Inline Jan 18 '17 at 13:21
  • Thank you I see. But I am not sure, in my local machine MySql works quite normal, there is no problem with it. I've received the failed messages from Travis CI. I'm gonna update my question. – Bálint Pap Jan 18 '17 at 14:03

1 Answers1

1

For CI tests you can use SQLite which is similar as MySQL and most of the frameworks are supporting. The problem with the Travis CI it is not providing a mysql database. The SQLite is just a in-memory database which located next to the source files.

PumpkinSeed
  • 2,945
  • 9
  • 36
  • 62