【问题标题】:Google Cloud SQL: Acess Denied from App Engine onlyGoogle Cloud SQL:仅来自 App Engine 的访问被拒绝
【发布时间】:2017-03-12 05:37:08
【问题描述】:

我正在同一个项目中从 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 尝试时:

代码sn-p:

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)  

我只用用户尝试了 url,但没有运气。
感谢任何建议。

【问题讨论】:

    标签: google-app-engine google-cloud-sql


    【解决方案1】:

    发现我的错误。 Java URL 应该是:

    url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root&password=passw0rd";
    

    我将 ; 替换为 &
    现在可以使用了。

    【讨论】:

    • 是的,GET 请求查询参数应该与&amp; 结合而不是;
    猜你喜欢
    • 2017-01-12
    • 2020-05-29
    • 1970-01-01
    • 1970-01-01
    • 2014-08-02
    • 2018-01-15
    • 2014-03-15
    • 2013-09-10
    • 1970-01-01
    相关资源
    最近更新 更多