简体   繁体   中英

JDBC MySQL Connection Error

I get the following error when trying to make a jdbc connection to a mysql database:

Attempting to connect to jdbc:mysql://localhost/castel castel castel
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'castel'@'%' to database 'castel'

I can connect to the database through the command line without a problem using the same credentials. I thought it might be a privilege issue so I ran:

GRANT ALL PRIVILEGES ON mysql.* TO 'castel'@'%'

Any help would be greatly appreciated.

OK the problem was completely unrelated to database configuration. It turns out my box had it's iptables configured to forward all traffic on port 3306 to another machine so I wasn't talking to the database that I thought was.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM