我尝试在我的Rails APP上使用SSL连接Google Cloud SQL,使用mysql cli和sslca,一切都很好。
$ mysql --ssl-ca=config/server-ca.pem --host=instance-ip --user=username --password
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1535
Server version: 5.6.26 (Google)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
这是我的database.yml
development:
adapter: mysql2
encoding: utf8
pool: 5
username: username
password: userpassword
host: instance-ip
database: RailsDB
sslca: config/server-ca.pem
当我启动rails服务器并尝试访问我的网站时,它会显示
Mysql2::Error (Access denied for user 'username'@'my-public-ip' (using password: YES))
这让我很困惑,它应该连接到Google Cloud SQL实例IP,但它会改为我的公共IP吗?
有什么想法吗?谢谢你的手表