I'm working on a maven sample project where in I use MySQL, Spring and Hibernate. I created a database using terminal in my mac. Used the following commands to log into mysql and create database and tables.
$ sudo -s
Password:
bash-3.2# mysql -u root -p
Enter password:
In my jdbc.properties file, I have this:
jdbc.driverClassName = com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/sample
jdbc.username = root
jdbc.password = root
hibernate.dialect = org.hibernate.dialect.MySQLDialect
hibernate.show_sql = true
hibernate.format_sql = true
On launching the url, I get to see this,
HTTP Status 500 - Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
root cause:
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
root cause:
org.hibernate.exception.GenericJDBCException: Could not open connection
root cause:
java.sql.SQLException: Access denied for user 'root '@'localhost' (using password: YES)
I'm not familiar using terminal and the commands. Can anyone let me know what is the issue here and what should be the jdbc.username and jdbc.password. I don't have a Query Browser, I've gotta use only the terminal.
I guess privileges are missing for "root@localhost"
Here are the steps to grant privileges
$ sudo -s
Password:
bash-3.2# mysql -u root -p
Enter password:
After you are logged in, grant privileges to root@localhost
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY 'thepassword' WITH GRANT OPTION;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.