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
):
Related Topics
How to Set Icon in a Column of Jtable
Java Operator Precedence Guidelines
Generics:List<? Extends Animal> Is Same as List<Animal>
Do Any Jvm's Jit Compilers Generate Code That Uses Vectorized Floating Point Instructions
In a Switch Statement, Why Are All the Cases Being Executed
Java Lib or App to Convert CSV to Xml File
How to Make a Jbutton in a Jtable Cell Click-Able
How to Resize Jlabel Imageicon
Java Date Year Calculation Is Off by Year for Two Days
Java - Reading, Manipulating and Writing Wav Files
Nullpointerexception Through Auto-Boxing-Behavior of Java Ternary Operator
Must Spring Component Classes Be Thread-Safe
How Does Java's Preparedstatement Work
How to Fix "The Expression of Type List Needs Unchecked Conversion...'