Setting root password via API

92 views
Skip to first unread message

Niklas B

unread,
Oct 12, 2016, 11:42:11 AM10/12/16
to Google Cloud SQL discuss
Hi,

I'm programatically creating SQL v2 instances+databases via Google Deployment Manager and wants to set root password via API (it can't be set via deployment manager) but can't figure out how to do it. It appears as it did exist a "InstanceSetRootPasswordRequest" in sqladmin_v1beta3 but this was removed in beta4. Is it possible to set root password via API? 

An admin daemon is responsible for creating the SQL instances across multiple projects which makes it almost impossible[1] to use the gcloud command and I really don't want to do it manually for each instance (there will be quite a few). 

I've (perhaps naively) assumed that I can't access the root user until I set a password but haven't had the time yet to test this. Worst case it's possible and I'll use the mysql client to change root password (if this is allowed). 

Any ideas? :)

Thank you!

Regards,
Niklas

[1] This would require me to programatically open a shell, write the json key contents (current held in memory) to a temporary file, run gcloud auth and then run gcloud ... set-root-password and pray that no other command will run gcloud auth between this request doing it and it running set-root-password

Jordan (Cloud Platform Support)

unread,
Oct 14, 2016, 11:01:13 AM10/14/16
to Google Cloud SQL discuss
As per our documentation there is currently no way to perform user management via the new Beta SQL v1beta4 API for Second Generation instances.

User management on Second Generation Cloud SQL instances is limited to the MySQL Client administration tool, setting the root password manually via the Console (as explained under the 'CONSOLE (2ND GEN)' tabs in our documentation), using the previous SQL v1beta3 API, and with the gcloud setRootPassword command as it uses the previous v1beta3 API. 

Our engineers are working hard on bringing this complete functionality to Second Generation instances, but there is currently no ETA for this. In the meantime, you could therefore create a script that uses the previous v1beta3 API or runs the gcloud command locally to set the root passwords for your newly created instances.  

Note, you can still use the Cloud SQL API, Console, and Cloud SDK to update user's passwords for First Generation Cloud SQL instances only.

Reply all
Reply to author
Forward
0 new messages