Java JDBC: "Access denied for user" Exception Resolved
When attempting to establish a connection to a MySQL database from a Java application, it is not uncommon to encounter a "java.sql.SQLException: Access denied for user..." error. This error message typically indicates that the specified user lacks the necessary permissions to access the database.
To resolve this issue, it is necessary to grant the appropriate privileges to the user in question. In this case, we will grant all privileges to the user 'vincent' from any machine:
mysql> grant all on db_name.* to 'vincent'@'%';
Replace 'db_name' with the name of the specific database that 'vincent' needs to access. Execute this query in the MySQL command line or through a tool like phpMyAdmin.
Once the grant query is executed, 'vincent' should have all necessary privileges and be able to connect to the MySQL database successfully.
The above is the detailed content of Java JDBC: How to Resolve \'Access denied for user\' MySQL Connection Errors?. For more information, please follow other related articles on the PHP Chinese website!