1
votes

I'm getting an error while trying to connect raspberry running ubuntu mate to my Google Cloud SQL instance.

These are the step I did to install:

git clone https://github.com/GoogleCloudPlatform/cloudsql-proxy
cd cloudsql-proxy/
sudo sh download_proxy.sh

My instance is configured this way (I deleted some characters in the image and in the code): Instance

I didn't set the network because I'll be using proxy

Then I download into the same folder my JSON key.

wget https://drive.google.com/file/d/my_key.json

And the start the proxy

sudo ./cloud_sql_proxy -instances=be   -     21:us-central1:be   =tcp:3306 \
                  -credential_file=./my_key.json &

But I'm getting the error:

pi@pi:~/cloudsql-proxy$ ./cloud_sql_proxy: 1: ./cloud_sql_proxy: Syntax error: ")" unexpected

I've tried removing the .json and I was getting the same error before without credential, I think that the problem is in the setup.

My dir ls is: dir ls

Any help is appreciated :)

3
Maybe cloud_sql_proxy didn't get downloaded properly? Try opening the file in a text editor, it sounds like the file doesn't have the right contents.Vadim
Hi. I can't because it's an executable :(EinSoldiatGott
Did you try? Based on the error you are getting there's something fishy with the file. What happens when you run file cloud_sql_proxy?Vadim

3 Answers

3
votes

download_proxy.sh downloads the proxy compiled for the amd64 architecture of CPU (aka x86_64). Your raspberry Pi has a ARM CPU, so this binary cannot run on your machine.

Google does not provide pre-build ARM versions of the proxy. I don't even know if it is able to build on ARM CPU. If it is possible, this is how you must do it:

  1. Install go, e.g. with apt-get install golang
  2. Setup a GOPATH, as per https://github.com/golang/go/wiki/GOPATH
  3. Run go get github.com/GoogleCloudPlatform/cloudsql-proxy/cmd/cloud_sql_proxy
  4. Run the proxy with $GOPATH/cloud_sql_proxy -instances=...
1
votes

Ok.

I'm sharing what I did to make it work, as David I don't know what version was I downloading.

I tried to avoid installing Go but it was the only way to get it installed.

sudo apt-get install golang-go
export GOPATH=$HOME/go
go get github.com/GoogleCloudPlatform/cloudsql-proxy/cmd/cloud_sql_proxy
cd $GOPATH/bin
wget your_key.json
sudo ./cloud_sql_proxy -instances=the_full_name_of_the_instance=tcp:3306 -credential_file=./your_key.json &

But I was getting a error because I already have mysql running localy in the same port

So now I'm using a unix soquet

sudo ./cloud_sql_proxy -instances=the_full_name_of_the_instance -credential_file=./your_key.json &

And then it's ready for connections :)

Thanks guys

0
votes

I found issues with this when compiling SQL-proxy. I did, however, find the instructions here worked great on my raspberry pi 3. Have to make sure to remove all prior installations then reinstall it

wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin # put into ~/.profile`