简体   繁体   English

播放2.3 Scala-MYSQL出现问题

[英]Play 2.3 scala - Slick with MYSQL issue

I am currently learning the Play Framework with MYSQL+Slick. 我目前正在使用MYSQL + Slick学习Play框架。

I have tried this Github sample to understand the MYSQL+Slick communication. 我已经尝试过这个Github示例来了解MYSQL + Slick通讯。

I am getting the exception below, even though I gave the correct DB credentials and DB. 即使我提供了正确的数据库凭据和数据库,也遇到了以下异常。

play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [models]]
    at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:94) ~[play_2.11-2.3.8.jar:2.3.8]
    at play.api.Configuration.reportError(Configuration.scala:743) ~[play_2.11-2.3.8.jar:2.3.8]
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:247) ~[play-jdbc_2.11-2.3.8.jar:2.3.8]
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:238) ~[play-jdbc_2.11-2.3.8.jar:2.3.8]
    at scala.collection.immutable.List.map(List.scala:273) ~[scala-library-2.11.6.jar:na]
Caused by: java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:998) ~[mysql-connector-java-5.1.35.jar:5.1.35]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3835) ~[mysql-connector-java-5.1.35.jar:5.1.35]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3771) ~[mysql-connector-java-5.1.35.jar:5.1.35]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:870) ~[mysql-connector-java-5.1.35.jar:5.1.35]
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1659) ~[mysql-connector-java-5.1.35.jar:5.1.35]

Does anybody know how I can resolve this issue? 有人知道我可以解决这个问题吗?

Please take the following actions: 请采取以下行动:

  1. In mysql, under root user: 在mysql中,root用户:

     CREATE USER 'test1'@'localhost' IDENTIFIED BY 'mypass'; CREATE DATABASE emp; GRANT ALL ON emp.* TO 'test1'@'localhost'; 
  2. Ensure you can login as 'test1' and have access to the emp database: 确保您可以以“ test1”身份登录并有权访问emp数据库:

     mysql -utest1 -pmypass use emp 
  3. Change credentials in your conf/application.conf : 更改conf / application.conf中的凭据:

     db.models.user="test1" db.models.pass="mypass" ... db.default.user="test1" db.default.pass="mypass" ... 

Then run your application. 然后运行您的应用程序。 This should work, at least without connection problems. 这应该工作,至少没有连接问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM