Connect heroku with Google Cloud MySql - mysql

I'm deploying a spring-boot backend for a react native mobile app on Heroku. Rather than using PostgreSQL in Heroku, can I know a way to connect Heroku with MySQL database which I have created in Google Cloud Platform(GCP)?
I tried to connect it with GCP using the application.properties file but it gives errors in Heroku.
The below code is used in application.properties file
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.datasource.url=jdbc:mysql://##.##.###.###/M######?useSSL=false
spring.datasource.username=###########
spring.datasource.password=#########

Related

How to connect Spring Boot app to MySQL in Compute Engine VM Instance and export it with HTTPS?

I'm trying to deploy a backend rest api on GCP built using Spring Boot. I start VM instance and install MySQL and connect to Spring app there, exporting network to port 8080 and I can access globally. The problem is, it can only be accessed by HTTP, not HTTPS. I read some articles to use App Engine and Cloud SQL but I have no idea how to connect to MySQL that I previously installed in that VM instance. I'm a student so I need to find the cheapest way to do it, can anyone help?

JDBC error when deploying Spring Boot application (docker image) on Raspberry Pi

I was trying to change the database source in my Spring Boot application because I did not want to give more money to Jeff Bezos hehe :D (I had RDS on AWS before).
When Im running the application on locally on my windows computer with localhost:3306, it works like a charm. I have installed MariaDb on my Raspberry Pi and created a database schema and I was thinking that when the app gets deployed (using docker container), it should connect to the database on the same url (localhost:3306/{dbName}) that I've preivously created. I have also tried to use the raspberry pi ip-address to connect to the MariaDb from my local windows computer and that works (192.168.x.xxx:3306/helloStackOverflow). So the problem occurs when connecting to the database locally on my Raspberry Pi.
Have I used the wrong ip and do I have to modify something in my enviroment.properties?
# Mysql Configuration
spring.datasource.url=jdbc:mysql://localhost:3306/helloStackOverflow
spring.datasource.username=root
spring.datasource.password=password
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
server.port=8080
Error message
What should I do?

GAE Python 3.7 Standard can't connect to Cloud SQL server

I'm following the tutorial for deploying a Django app on Google App Engine here. I'm able to run the app locally using cloud_sql_proxy, but when I deploy the app to GAE the app fails with the error:
(2003, "Can't connect to MySQL server on 'localhost' ([Errno 111] Connection refused)")
Checking the error output, it looks like django is trying to connect to the unix socket at /cloudsql/<project>:<region>:<instance> as expected, it's just failing for some reason. What could be causing this issue?
It looks like the problem was with the project I was using for the tutorial. Somehow the Google App Engine service account for that project had gotten its permissions revoked. After restoring those permissions (giving it the Editor role) the tutorial worked on the original project.
You need to change the database connnection in the Django settings.
appengine/standard_python37/django/mysite/settings.py
The settings.py file contains the configuration for your SQL database. The code in settings.py uses the GAE_APPLICATION environment variable to determine whether the app is running on App Engine or running on your local computer:
When the app runs on App Engine, it connects to the MySQL host by using the /cloudsql Unix socket.
When the app runs on your local computer, it connects to the MySQL host by using TCP, which requires a username and password.
Read the bottom of the documentation, here
Edit: make sure you've enabled the Cloud SQL API.

How to connect mysql when deploying node app on heroku

I have already deployed my node app with heroku which is working fine with my local phpmyadmin database but how can i use it without starting mysql on local machine.
OR how to connect my node app deployed in heroku with phpmyadmin(mysql2)
You shouldn't use local MySQL database in the production app which you have deployed in a hosting provider in this case Heroku.
You could create a remote MySQL database resource from providers like db4free.net.
Update your code to use database credentials of the remote database and start using it.
Note Heroku also provides a MySQL service. You could set up your database there too if you need.

Connecting to MySQL database located at (pythonanywhere.com) from app located at (heroku.com)

I created a webb app and deployed it at Heroku. So far, so good. Now I need to integrate it with the MySQL database which is located at pythonanywhere.com.
I tried the following command (which is what I managed to find when googling for accessing a remote MySQL database from Heroku):
heroku config:add DATABASE_URL=mysql2://PYTHONANYWHERE_USER:DATABASE-HOST-ADDRESS/DATABASE-NAME--app HEROKU-APP-NAME
Whenever I run this command from the console in Heroku, I get the following message:
bash: heroku: command not found
Have anyone tried connecting to a pythonanywhere MySQL database from Heroku before? Can you show how you did this step-by-step?
The reason why I want to access the PythonAnywhere database (and not just host it on Heroku) is that a lot of the backend is written on PythonAnywhere and stored on that database.
Thanks,
The heroku command is provided by the Heroku CLI, and should be installed and run from your local machine. Running heroku commands directly from a dyno (e.g., via heroku run bash) won't work.
Once you've set DATABASE_URL using heroku config you should be able to access it from your code via process.env.DATABASE_URL.