How can connect a Laravel Project to SQL instance on GCP? [duplicate] - laravel

This question already has answers here:
Connect local Laravel environment to Google Cloud SQL - MySQL
(3 answers)
Closed 3 years ago.
For my project I'm currently using Laravel 5.8 and my database is deployed on gearhost.com. Their service provide an hostname (mysql2.gear.host), a database name and a user (same as the database name)
I use these data to make the connection in my .env file:
DB_CONNECTION=mysql
DB_HOST=mysql2.gear.host
DB_PORT=3306
DB_DATABASE=myDatabaseName
DB_USERNAME=myDatabaseName
DB_PASSWORD=myPassword
The service is a bit slow and I'm trying to move to GCP. I have already created an instance and a database. Now I'm trying to figure out how to get an hostname address, but I can't
Is there a way to get these same data of an instance created on GCP?

If you are trying to connect to Cloud SQL from gearhost.com you can just follow the Cloud SQL documentation
In order to set a username and a password you can set them with this command
gcloud sql users set-password root --host=% --instance [INSTANCE_NAME] --password [PASSWORD]
Then you can look for the connection name of your instance using this command:
gcloud sql instances describe [INSTANCE_NAME]
After this, you can connect to your Cloud SQL using the proxy following the procedure stated in the documentation. You will get a dbSocket address to connect
dbSocket = '/cloudsql/INSTANCE_CONNECTION_NAME';
mysqli = new mysqli(null, $dbUser, $dbPass, $dbName, null, $dbSocket);

Related

How to connect to Oracle on SSMA tool?

Hope you can help. I'm trying to connect to an Oracle database using SSMA for Oracle.
I have created an Oracle VM on azure as highlighted below
and
the VM got created
I have added the firewall rule to allow 1521 port.
and created the DB as mentioned below
however I could not connect to the Oracle instance using SSMA
it is throwing the below error
and if I try with that account
it is not accepting the password
What is the Username and password to be used?
Reference: https://lovekesh.tech/how-to-install-oracle-database-in-microsoft-azure-vm/
I was able to fix this issue by using the "system" account instead of "sys" or "sysdba", passsword for "system" account is same as "sys" account.
and could convert the schema
and I see the progress as highlighted below
as well as I could migrate the data
and status is as shown below

On Prem to Cloud with Data Factory

I have one On Prem Oracle database and one Azure SQL Database and want to use a Copy Data activity to transfer this data.
I have now created a Self Hosted IR for the Oracle database, and I am able to connect to it and preview data from Data Factory editor:
I have a Azure SQL Database that I want to recieve data, and it is set up with AutoResolveIntegrationRuntime, with Connection successful. I am also able to preview data from this database:
When I try to run this Copy Data activity I get following error message:
ErrorCode=SqlFailedToConnect,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Cannot connect to SQL Database: 'sqlsrv', Database: 'database', User: 'user'. Check the linked service configuration is correct, and make sure the SQL Database firewall allows the integration runtime to access.
Based on all Docs/Tutorials I have read this should not be failing. I have tried to open up the SQL Server to allow all IP adresses in firewall rules.
Any ideas what I might be doing wrong here?
Since the integration runtime is a bridge across on prem and cloud , you need to check whether you are able to access the onprem database and the Azure SQL database through the VM in which the IR is installed.
The VM hosting the IR should be able to access both the source and sink for the copy activity to be successful in case if either of source or sink is using the self hosted runtime.
So the issue is not w.r.t Azure SQL database but in the VM hosting the IR

Connect Aurora Severless from tableau desktop and tableau server

It's a follow up question that I asked earlier here on Stack Overflow
Not able connect Amazon Aurora Serverless from SQL client
I found a cool hack that is working perfectly for my development purpose with some tweaks and I know I should not use this on my production environment.
So as we know Aurora Serverless works only inside VPC. So make sure you are attempting to connect to Aurora within the VPC and the security group assigned to the Aurora cluster has the appropriate rules to allow access. As I mention earlier that I already have an EC2 instance, Aurora Serverless and a VPC around both. So I can access it from my EC2 but not from my local pc/ local sql client. To fix that I did below two steps.
1. To access from any client(Navicat in my case),
a. First need to add GENERAL db configurations like aurora endpoint host, username, password etc.
b. Then, need to add SSH configuration, like EC2 machine username, hostip and .pem file path
2. To access from project,
First I create a ssh tunnel from my terminal like this way,
ssh ubuntu#my_ec2_ip_goes_here -i rnd-vrs.pem -L 5555:database-1.my_aurora_cluster_url_goes_here.us-west-2.rds.amazonaws.com:5432
Then run my project with db configuration like this way test.php,
$conn = pg_connect("host=127.0.0.1 port=5555 dbname=postgres user=postgres password=password_goes_here");
// other code goes here to get data from your database
if (!$conn) {
echo "An error occurred.\n";
exit;
}
$result = pg_query($conn, "SELECT * FROM brands");
if (!$result) {
echo "An error occurred.\n";
exit;
}
while ($row = pg_fetch_row($result)) {
echo "Brand Id: $row[0] Brand Name: $row[1]";
echo "<br />\n";
}
So what is my question now?
I need to connect my aurora serverless from tableau desktop and tableau server. For tableau desktop I used the same ssh tunneling and it works but how do I do it for tableau server?
Tableau Server does not support centralized data sources. You need to connect Tableau Desktop to your data source, and publish it to Tableau Server when you want to expose the data through the UI.
https://community.tableau.com/thread/111282

AWS RDS - ORA-28040: No matching authentication protocol exception

While connecting to Oracle 12c database from Java 8 client code, I got error -"ORA-28040: No matching authentication protocol exception" This was resolved by adding SQLNET.ALLOWED_LOGON_VERSION=8 in sqlnet.ora file.
Now, when I connect to AWS oracle RDS instance from code running in EC2 instance (RDS and java application running in same subnet), result in same error. Is there an option to add parameter(SQLNET.ALLOWED_LOGON_VERSION=8) in AWS Oracle RDS instance? How can resolve this issue?
The AWS docs list the params you can alter for your needs.
sqlnetora.sqlnet.allowed_logon_version_client
sqlnetora.sqlnet.allowed_logon_version_server
I suggest you to play with those.
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ModifyInstance.Oracle.sqlnet.html

Is possible to connect to RDS Oracle DB instance with SQL developer?

I'm trying to connect into my mac with the endpoint that AWS give me but i can't.
Yes, You can.
These are the AmazonRDS settings.
and this is the SQL Developer connection window
database host name should be the AWS endpoint & SID should be the AWS DB Name.
You can connect to database instance in RDS by using the endpoint and the credentials associated with the rds instance
Refer the below link for guidance:
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.Oracle.html
Also ensure that the security group associated with the RDS instance has appropriate port open for oracle connection.

Resources