travis mysql数据库创建用户错误 [英] travis mysql database create user error

查看:112
本文介绍了travis mysql数据库创建用户错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的spring-boot项目设置travis,使用用户makler/makler访问数据库.运行travis时出现错误消息:

I wanted to set up travis for my spring-boot project where I use user makler/makler for accessing database. When running travis I get an error saying:

$ 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.

我的travis.yml文件如下:

My travis.yml file looks like:

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';'

推荐答案

其围绕查询的引号.更新您的before_script以使用双引号()而不是单引号(')

Its the quotes surrounding the query. Update your before_script to surround the queries using double quotes(") instead of single quotes(')

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';"

在更改它并在travis上运行该构建后,该构建工作正常.希望这会有所帮助.

Build worked fine after I changed it and ran the build on travis. Hope this helps.

这篇关于travis mysql数据库创建用户错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆