Can't connect to ClearDB database after resetting password - node.js

I am trying to deploy a very simple nodejs api through Heroku and utilizing the clearDB add on so I can connect to the MySQL db the api utilizes. I had everything connected and working then realized I had hard coded and exposed the database user and password information. I reset the password on clearDB to reset the exposed information. So far I have created environment variables locally and the config variable for the new password on Heroku but now the app crashes anytime I try to connect to the db, is there somewhere else that the new password will be needed?

ClearDB stores the username and password information inside the URL to the db so if you only updated it in the config variable for the password you will also need to update it in the variable containing the URL string as well.

Related

can we revert change made to SQL Azure API connection?

I am new to Azure.
While editing the SQL API connection, mistakenly I added the wrong username and password for SQL server authentication.
can I revert this change to the previous version?
as I don't know the username and password for the database.
any help will be appreciated! Thanks in advance.
One of the workarounds is to change your connection directly from the connector itself.
While if you are trying to get the credentials from SQL Server, you can reset the password in the overview pane of your SQL Server.
and to know your username, in the same overview page you can find it under Server admin

MongoAtlas AWS IAM Role Authentication

I am setting up a deployment for my company's API Server and it fails to connect to MongoAtlas via IAM role
What I've done:
Set up a IAM Role on AWS (APIServer)
Set up a Database User on Atlas with the role (arn:aws:iam::< my aws acc id >:role/APIServer)
Configure a launch template and an auto scaling group, launching Amazon Linux EC2 instances with the role
Have my NodeJS application connect to my Atlas with the following setting:
key
value
URL
mongodb+srv://dev.< cluster >.mongodb.net/< DB >
authSource
'$external'
authMechanism
'MONGODB-AWS'
I ended up receiving the following error message
MongoServerError: bad auth : user arn:aws:sts::<my aws acc id>:assumed-role/APIServer/* is not found
Note: the info enclosed in <> are intentionally replaced, since I have already found several solutions pointing out having <> as part of the password, which is not my case here
I have the same problem, the only solution I found until now is to create a aws iam user (not a role, so you can generate security credentials), set up that user on atlas and put the security credentials of the user in a .env file in your node application. In this way mongodb will retrieve automatically that user and it works because you are not assuming a role, so the arn is correct.
This is still not a good solution to me, because I do not want to manage those keys. Best thing you can do probably is storing those credentials in aws secrets manager, give the ec2 role the permission to retrieve that secret, and when you start the instance with a script you can automatically retrieve the secrete and create the .env file.
(Still a disappointing solution to me)
Edit:
As I self answered in this post: AWS EC2 connection to MongoDB Atlas failing, could not find user
The solution for me was to change the scope of the Atlas user.
You need AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN to connect. You can get/create them from AWS IAM > Users dashboard. I recommend for mongo create a new secret key.
After creation you can get your connection string from mongodb website if you have already a cluster.
Example URL:
mongodb+srv://<AWS access key>:<AWS secret key>#cluster0.zphy22p.mongodb.net/?authSource=%24external&authMechanism=MONGODB-AWS&retryWrites=true&w=majority&authMechanismProperties=AWS_SESSION_TOKEN:<session token (for AWS IAM Roles)>

Resetting server admin password in Azure portal breaks deployed app

I reset the Server Admin password in the Azure Portal and it causes connections to fail.
I set up a new login and user in SqlServer to connect to an authentication database (I'm using Microsoft.AspNetCore.Identity) and changed the connection string to use this new user. This connection worked on my local machine, so I published the app. The connection was still good in the deployed app. I then reset the Server Admin password and within minutes all connections were failing on the deployed app. Is there another location in the portal that I need to change settings, or perhaps in my application code, so that connections don't fail?
I've tried changing the connection strings in the app service configuration settings on Azure Portal, with no effect.
If you reset the Server Admin password, the SQL database connection string also changed, you need to get the new connection string or replace the username and password with your new password in old connection string. please try again.
Rest admin password:
Connection string:
Replace the {your_username} and {your_password} with new admin password in old app connection string, your connection string should like this:
Server=tcp:***.database.windows.net,1433;Initial Catalog=db_name;Persist Security Info=False;User ID=username;Password=new_admin_password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;
Hope this helps.

Can i use a single user to connect different databases in MongoDB?

I hava tried to create a user in database "admin" with roles of "root","readWriteManyDatabase" in mongodb to connect to different databases, but it seems that i can not use
this user to directly connect to the other databases, but i can do operations on other databases after run db.auth() in database admin.
So, is there any way i can use to connect directly to different databases with a same user but do not need to first connect to database "admin"
Make sure you're authentication with the admin database when connecting to the database server, this can be specified on the MongoDB Connection string by passing a query string parameter of authSource. For example:
mongodb://username:password#my-server/my-db?&authSource=admin
If you don't specify an auth source then it will try to authenticate using the database specified, in this case my-db
If you're using the shell you can specify this as an arugment of authenticationDatabase for example:
mongo localhost -u user -p password --authenticationDatabase admin

Change password in MySQL in App - Microsoft Azure

How can I change the password of user azure in MySQL in App?
What I have tried so far:
There are two configuration files named MYSQLCONNSTR_localdb.txt and MYSQLCONNSTR_localdb.ini. I have changed the default password there, but nothing happened. Also, if I change the password using PHPMyAdmin, then I cannot login again to PHPMyAdmin (for reasons unknown to me) using the new credentials.
Quoting the doc:
Can I customize the database, username and password to be used?
Yes. The connection string is stored at
D:\home\data\mysql\MYSQLCONNSTR_localdb.txt. The application (such
as wordpress) reads from this file for what database, username and
password to use. This also applies to what to backup and restore
provided by Azure WebApps. If you want to customize the database,
username and password, after you have created a new database, add new
username or update password, simply modify
D:\home\data\mysql\MYSQLCONNSTR_localdb.ini, remove
D:\home\data\mysql\MYSQLCONNSTR_localdb.txt and restart the WebApps.

Resources