Java Jdbc Access Denied for User

Java JDBC Access denied for user

Try granting all privileges to your user from any machine in mysql:

 grant all on db_name.* to ‘vincent’@'%';

where db_name is your database name ...

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

As you are creating a database from scratch, you could use:

Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/?user=root&password=rootpassword"); 
PreparedStatement ps = connection.prepareStatement("CREATE DATABASE databasename");
int result = ps.executeUpdate();

Here is an identical scenario.

Access denied for user 'root '@'localhost' when connecting to mysql

Remove the spaces on the sides of the = signs in your application.properties. And also make sure you have no spaces after the values (notice in your question title it's trying to log in as root with a space after the t).

You do have spaces after root in the copy/pasted data in the question (couldn't possibly know in your real file)

Look at a screenshot of your question with the text selected (notice after root):

Copy/paste spaces image



Related Topics



Leave a reply



Submit