I'm following this document Google Cloud - Connect Instance Private IP
to connect to my Cloud SQL instance with GCE via private IP.
Both Cloud SQL and GCE are on the same VPC network and in the same region and zone. I've also enabled Cloud SQL Admin API
I got The proxy has started successfully and is ready for new connections! from one of the ssh windows and tried to connect via another ssh window as per the instructions
mysql -u root -p --host 127.0.0.1 --port 3306
but I got
-bash: mysql: command not found
Does anyone know how I can successfully connect?
I tried to install mysql
The error message is still the same:
mysql -u root -p --host 127.0.0.1 --port 3306
-bash: mysql: command not found
This is Jonathan from Google Cloud SQL Connectors team. I see that you are having a problem with your mysql command. The error you are getting:
means that your shell can't run the
mysqlcommand that you installed. To check if this is the problem, run this command:If your mysql executable is in the path, then this will print out the absolute path of the mysql executable. If this prints out "mysql not found", then your bash shell can't find the mysql executable.
There are a few ways to solve this. Suppose you downloaded the mysql tar.gz distribution and extracted it into this directory:
/home/me/Downloads/mysql-8.0.2First make sure that the mysql executable is marked as executable on your file system by running the terminal command:
chmod a+x /home/me/Downloads/mysql-8.0.2/bin/mysqlThen, there are three ways to update you could update your environment so that you can run the mysql command:
/home/me/Downloads/mysql-8.0.2/bin/mysql -u root -p --host 127.0.0.1 --port 3306(adjust the path for your system)cp /home/me/Downloads/mysql-8.0.2/bin/mysql /usr/local/bin &&export PATH=$PATH:/home/me/Downloads/mysql-8.0.2/binI hope that helps get you going with Google Cloud SQL.