Search code examples
mysqlgoogle-cloud-platformgoogle-cloud-sql

Unable to configure mysql database, after cloud sql proxy setup


Configured cloud sql proxy, as per this link https://cloud.google.com/sql/docs/mysql/connect-admin-proxy

Enabled the Cloud SQL Admin API. while connecting to mysql with following command getting below error

[prudvee143@centos-2 ~]$ mysql -h 127.0.0.1 -u root -p
Enter password: 
2018/12/11 02:21:34 New connection for "bookshelfs-221608:us-central1:test"
2018/12/11 02:21:34 couldn't connect to "bookshelfs-221608:us-central1:test": ensure that the account has access to "bookshelfs-221608:us-central1:test" (and make sure there's no typo in that name). Error during createEphemeral for bookshelfs-221608:us-central1:test: googleapi: Error 403: Access Not Configured. Cloud SQL Admin API has not been used in project 317520816688 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.com/overview?project=317520816688 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry., accessNotConfigured
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Commands used for this:

wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 -O cloud_sql_proxy
chmod +x cloud_sql_proxy

[prudvee143@centos-2 ~]$ 2018/12/11 02:14:55 failed to setup file descriptor limits: failed to set rlimit {&{8500 4096}} for max file descriptors: invalid argument
2018/12/11 02:14:55 using credential file for authentication; [email protected]
2018/12/11 02:14:55 Listening on 127.0.0.1:3306 for bookshelfs-221608:us-central1:test
2018/12/11 02:14:55 Ready for new connections

Solution

  • The solution is to enable the Cloud SQL API.

    You can enable the API using the Google Cloud Console:

    1. Go to APIs & Services
    2. Go to Library
    3. Enter SQL in the Search for APIs & Services
    4. Select Cloud SQL Admin API
    5. Click Enable.

    You will also need to enable Cloud SQL. Repeat the above steps.