I want to connect to my database and create the tables using Java. Butm It throws below exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database
I want to connect to my database and create the tables using Java. Butm It throws below exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user ''@'localhost' to database
Check if user is allowed for remote connection, run below sql query on your database to allow your user to connect from everywhere.
Allow a user to connect from anywhere
`GRANT ALL ON *.* to <user-name>@'<ip>' IDENTIFIED BY '<password>'`
Sample for root
user :-
GRANT ALL ON *.* to root@'%' IDENTIFIED BY 'root';
// grant root user to connect from everywhere(%) , which has root password.
Have you add a new user
in your database with all rights
(write - read) ?
Is the URL of your database correct ? For example like :
jdbc:mysql://localhost:8000