2016-08-15 2 views
5

Ich wollte Travis für mein Spring-Boot-Projekt einrichten, wo ich Benutzer Makler/Makler für den Zugriff auf die Datenbank verwenden. Wenn travis laufen bekomme ich eine Fehlermeldung, dass:Travis Mysql Datenbank Benutzerfehler erstellen

$ mysql -u root -e 'CREATE DATABASE stockmarket;' 

$ mysql -u root -e 'CREATE USER 'makler'@'localhost' IDENTIFIED BY 'makler';' 
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'makler' at line 1 


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

Your build has been stopped. 

Meine travis.yml Datei wie folgt aussieht:

language: java 
jdk: 
    - oraclejdk8 
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 stockmarket;' 
    - mysql -u root -e 'CREATE USER 'makler'@'localhost' IDENTIFIED BY 'makler';' 
    - mysql -u root -e 'GRANT ALL ON stockmarket.* TO 'makler'@'localhost';' 

Antwort

8

Die Anführungszeichen um die Abfrage umgibt. Aktualisieren Sie Ihre before_script die Abfragen mit doppelten Anführungszeichen zu umgeben (") anstelle von einfachen Anführungszeichen (')

before_script: 
- mysql -u root -e 'CREATE DATABASE stockmarket;' 
- mysql -u root -e "CREATE USER 'makler'@'localhost' IDENTIFIED BY 'makler';" 
- mysql -u root -e "GRANT ALL ON stockmarket.* TO 'makler'@'localhost';" 

gebaut hat gut funktioniert, nachdem ich es geändert und lief die Build auf travis. Hoffe, das hilft.

Verwandte Themen