Google Cloud SQL: Acess Denied from App Engine only - google-app-engine

I'm accessing Cloud SQL from App Engine in the same project. I have set the password to the root user. I'm able to connect from mysql command line remotely thusly:
C:>mysql -u root -h xxx.xxx.xxx.xxx -p <- IP address of my Cloud SQL
Enter password: <--- I supply passw0rd
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 20913
Server version: 5.7.14-google-log (Google)
However, when I try from App Engine:
Code snippet:
url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root;password=passw0rd";
conn = (Connection) DriverManager.getConnection(url);
The error I get is:
com.google.gae.server.Connect getConnection: ERROR. Could not get connection. Access denied for user 'root;password=passw0rd'#'cloudsqlproxy~xxx.xxx.xxx.xxx' (using password: NO)
I have tried the url with just the user only, but no luck.
Appreciate any suggestions.

Found my error. The Java URL should have been:
url = "jdbc:google:mysql://myproject:us-central1:myinst/mydb?user=root&password=passw0rd";
I replaced the ; with &.
Works now.

Related

how to connect samba AD DC to koha ldap

I have installed koha 20.11 and samba4 AD and Kerberos .
I have tried to connect by the terminal using the below LDAP search query and its working fine,
$ ldapsearch -H ldap://MyIp -x -D "CN=Administrator,CN=Users,DC=domain,DC=in" -w "pass#123" -b "CN=Users,DC=domain,DC=in" sAMAccountName=admin
I want to connect samba AD to koha LDAP.
but I am getting the following error.
LDAP search failed to return object : 00002020: Operation unavailable without authentication at /usr/share/test_koha/lib/C4/Auth_with_ldap.pm line 98.
samba configuration :
[global]
dns forwarder = <myIp>
netbios name = DC1
realm = <DC my domain>
server role = active directory domain controller
workgroup = <DC>
idmap_ldb:use rfc2307 = yes
server services = rpc, nbt, wrepl, ldap, cldap, kdc, drepl, winbind, ntp_signd, kcc, dnsupdate, dns, s3fs
#ldap server require strong auth = no
ldap server require strong auth = no
[sysvol]
path = /var/lib/samba/sysvol
read only = No
[netlogon]
path = /var/lib/samba/sysvol/<DC my domain>/scripts
read only = No
koha ldap conf.:
<useldapserver>1</useldapserver><!-- see C4::Auth_with_ldap for extra configs you must add if you want to turn this on -->
<ldapserver id="dc1">
<hostname>ldap://ldap domain</hostname>
<base>CN=Domain Computers,CN=Users,DC=koha,DC=kohaconnect,DC=in</base>
<user>CN=Administrator,CN=Users,DC=koha,DC=kohaconnect,DC=in</user>
<pass>pass#123</pass>
<replicate>1</replicate>
<update>1</update>
<auth_by_bind>1</auth_by_bind>
<update_password>1</update_password>
<principal_name>CN=%s#koha.kohaconnect.in</principal_name>
<mapping>
<userid is="sAMAccountName"></userid>
<password is=""></password>
</mapping>
</ldapserver>
NOTE : we are not using koha`s default command, i.e. koha-common and service memcached.
• You are getting this error because you have not restarted the koha-common service and the Memcached service inherent. You can do so by running the below command and checking if the configuration has correctly been done for you: -
‘ $ service koha-common restart && service memcached restart
$ export PERL5LIB=/usr/share/koha/lib/ && export KOHA_CONF=/etc/koha/sites/library/koha-conf.xml && perl /usr/share/koha/opac/cgi-bin/opac/opac-user.pl userid=user1 password=password ‘
Please ensure to adapt the path to the koha-conf.xml, as well as user and password. Also, please note that you can bind to LDAP as user at REALM or NT4DOM\username. So, try doing that.
Find the below link for reference: -
https://openschoolsolutions.org/koha-ldap-setup/

Failed to connect to Database - Setting up GCP app engine

I'm trying to setup an instance on my phoenix app. I'm actually able to generate the app but I'm getting an error when trying to connect to the DB:
ERROR:
21:11:31.017 [error] Postgrex.Protocol (#PID<0.2223.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (/tmp/cloudsql/statcasters:us-central1:statcastersdb): no such file or directory - :enoent
I'm not sure what is wrong? The file seems to exist but it seems to say it doesn't:
prod.secret.exs:
config :statcasters, Statcasters.Repo,
username: "postgres",
password: System.get_env("DATABASE_PASSWORD"),
database: "statcasters_prod",
socket: "/tmp/cloudsql/statcasters:us-central1:statcastersdb",
pool_size: 20
I'm not sure what more information I can give? Does anybody know what I could be missing here?
There are 2 flavors of App Engine so please see the instructions linked here: https://cloud.google.com/sql/docs/postgres/connect-app-engine
The socket name appears to include a redundant "/tmp" prefix and should start with "/cloudsql/..." for App Engine standard.

I can't connect to the Google app engine flexible environment instance. Node.js

I got timed out error when I used SSH. I want to fix it. Can you please help me?
Welcome to Cloud Shell! Type "help" to get started.
...
$ gcloud --project "xxx" app instances ssh "xxx" --service "xxx" --version "xxx"
ssh: connect to host xx.xx.xx.xx port 22: Connection timed out
ERROR: (gcloud.app.instances.ssh) [/usr/bin/ssh] exited with return code [255].
I read the documentation. https://cloud.google.com/appengine/docs/flexible/nodejs/debugging-an-instance
I tried it on cloud shell and pressed the SSH button as well. I use Nodejs runtime.
I have owner role.
The 255 error usually occurs due to either a permission or firewall issue. As in your case you have the Owner role, I'd try with the firewall settings. Create a new one allowing an IP range of 0.0.0.0/0 as described in the steps here.

Laravel/Homestead - can't connect to the DB

I have installed homestead on my machine and cloned a project from a remote repository, now I am trying to create a DB for my project.
This is how my .env file looks like:
APP_ENV=local
APP_DEBUG=true
APP_KEY=base64:e7K7SUDgogNqTtP9TO1CfpbXFAC6FmLLSJ1l6K8pbWs=
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=localhost
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
I have tried to connect to DB using sequel pro standard option:
Host: localhost
Password: secret
But I get:
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary
privileges, or try increasing the connection timeout (currently 10
seconds).
MySQL said: Can't connect to MySQL server on '127.0.0.1' (61)
What am I doing wrong?
Some options:
Check the service of mysql is running;
Check the user and passowrd are correct;
Check the privilege of the user, try root user
For Mysql Connection you should have check username and password. and .env file
DB_HOST=localhost
DB_DATABASE=Your Database name
DB_USERNAME=username
DB_PASSWORD=password
Along With that, you can update database.php file for database configurations.
I had to add the port 33060 to be able to connect. Hope that will help others who got stuck like me.
I have some problem with Laravel 7 Homestead. I solve the error with this step:
Use mysql port 33060
Clear laraver config. php artisan config:clear
Reload vagrant vagrant reload --provision
And make sure your database name and password is correct.
Happy coding.

Heroku database push operation

To load a database which runs now on the my computer, SQL Server 2012 and Windows, I have installed Git Bash, taps and Heroku.
Now, whenever I wrote the command
heroku db:push --app myapp
it gives the same error
Invalid database ur
I think I miss something, I have not declared which database should be pushed to the Heroku.
Can you help me with this problem ? how can I use heroku db:push, are there any other steps like creating something ? Why I get this error ? Maybe you will say that "have you read documentation or have you searched google?", Yes
EDIT: What I have know is
Local database
Server name Heroku database
Database name application name
username | or windows authentication postgres database
password | username and password
aws address
Should I put/load some file/gem into the Git ?
EDIT 2:
I have test this command but it gives other error.
heroku db:push postgres://localdbUSERNAME:localdbpassword#localdbDATABASENAME/localdbSERVERNAME --app myapp
Error
Failed to connect to database:
Sequel::AdapterNotFound -> LoadError: cannot load such file -- pg
Heroku db:push does not work with SQL Server, it works with MySQL and/or Postgres. You'll need to switch to running one of these database servers, run your migrations/seeds and then use heroku db:push to push your local database to Herokul

Resources