I try to connect my Laravel project into my local development environment to Google Cloud SQL (MySQL).
For this, I connected from my OSX Terminal with the Cloud SQL-Proxyclient to the remote database with port 3307.
I can connect with my MySQL Workbench to the remote database, and I can see/change tables, ...
Into my Laravel project into .env I changed the settings:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3307
DB_DATABASE=mydatabasename
DB_USERNAME=mydatabaseusername
DB_PASSWORD=mydatabasepassword
When I open my project into the browser, into terminal I can't see, that something tries to use the connection.
Into the browser I get an error message:
SQLSTATE[HY000] [2002] No such file or directory (2002)
I think, the project can't connect to the remote database
How can I solve this problem?
Thanks for help!
While the Cloud SQL Proxy connects to your database on port 3307, you want to connect to the Cloud SQL proxy on port 3306 (this is the default mysql port). You can also specify a custom port by updating the instances argument:
./cloud_sql_proxy -instances=my-project:us-central1:sql-inst=tcp:3306 &
I added now the public IP address of the server, and I added my local IP address to allowed IP adresses for the MySQL server. Now it works.
Make sure you have config for right DB_HOST. Let get an IPv4 Read this for more informations:
https://cloud.google.com/sql/docs/mysql/connect-external-app#appaccessIP
Related
I am working on a school assignment and have to hand in my application on a virtualbox machine. The MySQL on there isn't working so I am trying to connect my spring boot application to an online database instead of the one on localhost, but I am clueless what I should enter on the spring.datasource.url.
Current code:
spring.datasource.url=jdbc:mysql://localhost:3306/smalleducator_db?useSSL=true&serverTimezone=CET
spring.datasource.username=root
spring.datasource.password=
Does anyone know what I should enter at datasource.url to connect to my online database? I have a server IP, database name, username and password. I have tried:
spring.datasource.url=jdbc:mysql://aaa.bbb.ccc.ddd:3306/smalleducator_db?useSSL=true&serverTimezone=CET
But I am getting this error:
Could not obtain connection to query metadata : null, message from server: "Host '213.127.85.xxx' is not allowed to connect to this MariaDB server".```
Yes, you are doing it right. It seems that your database is not configured for remote access. Make sure your port is open and you can access the database from remote (https://mariadb.com/kb/en/library/configuring-mariadb-for-remote-client-access/) and then add the correct hostname or IP address to your configuration:
spring.datasource.url=jdbc:mysql://HOSTNAME_OR_IP:3306/smalleducator_db?useSSL=true&serverTimezone=CET
spring.datasource.username=root
spring.datasource.password=
I just created a google cloud postgres with very basic authorization by whitelist the ip.
Google Cloud Auhtorization
I successfully connected to the google cloud postgres (35.240.xx.xx) from my home (139.193.xx.xx) using pgadmin and successfully created tables and inserted initial ddl.
pgadmin
When I want to use it in the shared hosting (119.81.xx.xx) that hosts laravel php application, I changed it in the .env file as below.
DB_CONNECTION=pgsql
DB_HOST=35.240.xx.xx
DB_PORT=5432
DB_DATABASE=postgres
DB_USERNAME=postgres
DB_PASSWORD=[google cloud password here]
But it didn't connect when I run the website with laravel.log as below.
[2018-07-12] ERROR: SQLSTATE[08006] [7] could not connect to server:
Connection refused Is the server running on host "35.240.xx.xx" and
accepting TCP/IP connections on port 5432? {"exception":"[object]
(PDOException(code: 7): SQLSTATE[08006] [7] could not connect to
server: Connection refused
Can anyone help me? Thanks.
It turns out that the shared hosting needs to also whitelist google cloud external ip address. It's working now.
I will create new server with database pgadmi4 and use data from heroku.
I get this kind of problem...
thaks :)
This has nothing to do on pgAdmin4 side, You need to configure your AWS instance to accept incoming connection from your IP address and update pg_hba.conf accordingly.
i have tried to connect from Jmeter to external mysql server using JDBC sampler. But I am getting erros. its possible to connect to the local mysql server.I am confused how to connect jmeter from my local machine to server database in other machine using JDBC CONNECTION
Make sure you remote MySQL server is accepting remote connections. Locate bind-address line in my.cnf file and set it to listen on all interfaces:
bind-address = 0.0.0.0
See Troubleshooting Problems Connecting to MySQL for more details. You will need restart MySQL server in order to pick up any changes made in my.cnf file
Make sure your operating system firewall on MySQL server side allows incoming connections to MySQL server TCP port (default is 3306).
Verify that you able to hit port 3306 with a telnet client or equivalent
If you will be still experiencing problems - update your question with JDBC Request sampler output and jmeter.log file contents. I would also recommend checking out The Real Secret to Building a Database Test Plan With JMeter to learn more about the concept of databases load testing using JMeter
If you are able to connect to that server using MySQL Workbench or another tool just use the below config for JMeter.
Just remember that you need to have mysql-connector-java-5.1.40-bin.jar (or another version of it) under apache-jmeter-3.0\lib\ folder.
Hope this helps!
Hi again i want to connect to cleardb instance in heroku i take hostname and credentials from heroku config vars in CLEAR_DATABASE_URL but i am getting the following error
ERROR 2003 (HY000): Can't connect to MySQL server on 'us-cdbr-east-06.cleardb.net' (111)
im trying to connect in this way
mysql -u username -p -h us-cdbr-east-06.cleardb.net
any idea why i am getting 111 error?
thanks for your time
Error fixed thanks the help from cleardb support team, here support answer
Hi there,
Thanks for reaching out. You may want to check with your local network
administrator and/or ISP to ensure that you are allowed to access
remote resources that run on TCP 3306. It is possible that this port
has been blocked from your local network and/or machine. To be clear,
we performed a connection test on this database and found that it is
operating normally, so the next diagnostic step is to check your local
connectivity to remote MySQL databases.
Hope this helps,
member team