我正在同一个项目中从App Engine访问Cloud SQL。我已将密码设置为root用户。我可以远程从mysql命令行连接:
C:>mysql -u root -h xxx.xxx.xxx.xxx -p <- IP address of my Cloud SQL
Enter password: <--- I supply passw0rd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20913
Server version: 5.7.14-google-log (Google)
然而,当我从App Engine尝试时:
代码段:
url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root;password=passw0rd";
conn = (Connection) DriverManager.getConnection(url);
我得到的错误是:
com.google.gae.server.Connect getConnection: ERROR. Could not get connection. Access denied for user 'root;password=passw0rd'@'cloudsqlproxy~xxx.xxx.xxx.xxx' (using password: NO)
我只尝试了用户的网址,但没有运气 感谢任何建议。
答案 0 :(得分:0)
发现我的错误。 Java URL应该是:
url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root&password=passw0rd";
我将; 替换为&amp; 立即行动。