简体   繁体   中英

How to connect to mysql UNIX server from java windows application using jdbc?

I am working on java windows application. I am trying to connect to mysql server(Localhost via UNIX socket) using jdbc. But it is displaying an error message as
"Access denied for user 'root'@'ipaddress'. I didn't get what is the problem.Is it the problem connecting to unix server from jdbc? If so how can I resolve this issue.Please help me regarding this.

在此处输入图片说明

Thanks in advance

You need to set up mysql to allow remote connection for any users. The default syntax is:

grant on to @ identified by

eg grant all on test.* to root@ipaddress identified by root

Will allow 'root' to connect from that IP using that password and give all permissions on all tables in that database.

Try this

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';

Also, before testing your java app, try connecting using mysql workbench or another client. Only after it succeeds run the java app.

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