Connecting Wordpress on Google Cloud Compute to CloudSQL DB - google-compute-engine

Ive tried and tried to get this to work to no avail.
I have WordPress running on Google Computer Engine, and I have my database on Google CloudSQL. Both are in the same project, and I have managed to connect to MySQL via the CloudSQL Proxy with:
./cloud_sql_proxy -dir=/cloudsql -instances=[CLOUDSQL INSTANCE CONNECTION] & mysql -u [CLOUDSQL USER] -S /cloudsql/[CLOUDSQL INSTANCE CONNECTION]
This brings up the mysql command where I can show my databases in that remote connection.
I am not sure if I need to put something in my wp-config.php file to pick up on the CloudSQL Database or what.
I already have the scope set to allow CloudSQL access, and I am able to actually connect from GCE over to the CloudSQL DB, but I am not sure how to get wordpress to access the DB.
I saw this here: Connecting Google Cloud SQL with Wordpress on Google Compute Engine But it didn't help me because I wasn't sure exactly what needed to be done.
I would be EXTREMELY greatful for any help.

Although you use Google Compute Engine instead of Google App Engine to host your WordPress, the configuration "wp-config.php" should be very similar to the code in https://github.com/GoogleCloudPlatform/appengine-php-wordpress-starter-project/blob/master/wp-config.php as described in http://googlecloudplatform.github.io/appengine-php-wordpress-starter-project/. You should set DB_HOST to ":/cloudsql/[CLOUDSQL INSTANCE CONNECTION]".

Related

Why is my MySQL Database on AWS not accessible?

I cannot reach my MySQL Database instance I created on AWS.
What I tried was to set the public access of the Database to "Publicly accessible" here:
Also I tried to set Inbound/Outbound rules for the MySQL port here:
Honestly I think using "All" ports would include 3306 too. Anyways, I tried it this way because yet it didn't work. I cannot connect to the database via MySQL Workbench, nor can I use a ping request on the given endpoint.
I would be glad if someone here has an idea what I could try else.
This will not work if you have deployed it in a private subnet which has no internet access.
Another possibility is that there is ACLs that is stopping the traffic. Security group only touch the RDS instance, the ACLs control traffic in the entire subnet.
Here is a dev AWS tutorial that creates a web application that stores data in MySQL running on the cloud. It will show you how to setup the database and the inbound rules. Once you do, you can store data or query data from MySQL. Likewise, you can use MySQL Workbench to interact with MySQL on the cloud.
AWS RDS Tutorial

How to connect Google Data Studio with AWS RDS MySQL behind VPC?

I have a AWS RDS MySQL database hosted inside VPC. I am having problem with connecting Google Data Studio since it's obviously outside the VPC.
I have enabled Publicly Accessed option in the RDS but still can't connect, even from MySQL Workbench.
Anyone has successfully connect between AWS RDS MySQL inside VPC and Google Data Studio? What's the setup and configuration?
I have posted a similar question to connect MySQL & Google Data Studio (while having SSL enabled). My latter question still needs to be answered, but I actually got MySQL Workbench to work with our AWS RDS MySQL-DB.
Steps:
Add SSL access to the AWS's MySQL database user as recommended in the documentation: GRANT USAGE ON *.* TO 'encrypted_user'#'%' REQUIRE SSL;
Add your current IP address to the AWS instance's firewall-whitelist, to allow for remote MySQL DB access.
Add hostname, port (3306), encrypted_user (created above) and password.

Cannot set tcp_keepalive_time on google cloud compute engine instance

we are running a node.js server that needs to connect with a mySQL database. We hosted our database on amazon RDS, but now we've moved it over to Google SQL and we're having trouble with the server randomly dropping the connection after 10 minutes.
Apparently that's a feature, not a bug, and the workaround is setting a low tcp keepalive in the machine we're connecting from, as described here: https://cloud.google.com/sql/docs/diagnose-issues
The code should be:
echo 'net.ipv4.tcp_keepalive_time = 60' | sudo tee -a /etc/sysctl.conf
sudo /sbin/sysctl --load=/etc/sysctl.conf
Unfortunately, when running the code I get:
sysctl: cannot stat /proc/sys/net/ipv4/tcp_keepalive_time: No such file or directory
We have root access to this machine, but we can't even manually creating a file named tcp_keepalive_time in this folder.
We're extremely puzzled, as the solution comes from the official google Cloud SQL docs and should therefore work as described.
Has anyone got any insights to share? Thanks in advance :)
Auto-answer:
You can't access the filesystem as admin (apparently) from the web/cloud console.
We used gcloud auth (from the gcloud SDK) to log in from the therminal, puttygen to create a SSH key and then putty to SSH into the machine from a proper ssh client (instead of the cloud SSH console), and sure enough it worked.
Weird, hope this helps someone else with the same issue!

Connecting Google Cloud SQL with Wordpress on Google Compute Engine

I've been running a successful Wordpress install on Google Compute Engine with Nginx, Php-fpm and Mysql.
I noticed you can also run Wordpress on App Engine with a Cloud SQL connection as mentioned here https://developers.google.com/appengine/articles/wordpress?hl=en
I want to use Wordpress on Compute Engine with the db running on Cloud SQL.
On AppEngine, you need to put the following lines in the wp-config.php file
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) {
define('DB_HOST', ':/cloudsql/YOUR_PROJECT_ID:wordpress_db_name');F
}else{
define('DB_HOST', 'localhost');
}
Is there a similar way to connect Wordpress on Compute Engine with Cloud SQL?
No. There is no need to connect to fancy socket names, you need to set up Wordpress as a usual MySQL client, just keep in mind that you need to pre-authorize Compute Engine instance to access your Cloud SQL instance.

how to connect local mysql to gae rdbms

I have set up MySQL on my local computer and now I want to connect to the gae cloud database so I can use sql to load my data into gae. I got the local MySQL working using the documentation in google developers and they hint at connecting to the gae database but they don't give enough detail to do it for a new user.
I have tried many methods such as:
c:\mysql -u host:app-id.appspot.com -p
and c:\google_sql.cmd app-id.appspot.com [guestbook]
Thankyou for your help
Dan