-1

hi i have lost my aws database master pasword .i knew that how to reset rds password using below link https://aws.amazon.com/premiumsupport/knowledge-center/reset-master-user-password-rds/ but the problem is that i dint find any db instance in aws console. my app is running well. so there is backend db working properly .i have my privete key file . so can any one help how to reset my aws database master password,

EC2 Instance

my sg details

sg details in bound rules

Mohit-Tech
  • 102
  • 7
  • It sounds like your problem is not that you don't know how to reset the database password, but that you don't know how to find your database. Are you sure you are looking in the correct AWS region? Are you sure your database is running on RDS instead of on an EC2 server? – Mark B Aug 20 '20 at 13:31
  • Well, @MarkB is correct. You need to find out your DB before asking for password reset. You can check your Application Security Group and find out other SGs, once you get the Database SG, try figuring out which RDS/EC2 is using it. After that try resetting password. – CK__ Aug 20 '20 at 14:18
  • You can find out DB SG reference in EC2 SG console by putting Application SGs ID in search bar. – CK__ Aug 20 '20 at 14:20
  • @ChandanKumar i have only one ec2 instance .and two SG.but icant find my db using this any idea about it?? – Mohit-Tech Aug 21 '20 at 03:35
  • Hmm...can you add screenshot of your EC2 instance details and SG page's screenshot in question? You can blur out IPs or any other sensitive data. – CK__ Aug 21 '20 at 03:41
  • @ChandanKumar i have added screenshorts as u said – Mohit-Tech Aug 21 '20 at 03:57
  • As you said you don't see any DB in RDS console too this and further looking on the screenshots, I strongly believe you have DB and Application on the same Instance. I would suggest you to check if DB port is open in Inbound Rules of your EC2 instance. For example you can check for port 3306 if it's My SQL or check for port 5432 if it's PostgreSQL else check for any custom port too. – CK__ Aug 21 '20 at 04:28
  • @ChandanKumar i can see MYSQL/Aurora TCP 3306 in inbound rule s.there is four entries of it with different source. – Mohit-Tech Aug 21 '20 at 04:57
  • Great! We are into right direction now. Can you add that SG's screenshot(showing Inbound rules) too in the question. This will confirm my doubt. – CK__ Aug 21 '20 at 05:04
  • @ChandanKumar i have added screen short for SG's screenshot(showing Inbound rules) – Mohit-Tech Aug 21 '20 at 05:23
  • Alright, can you login into your EC2 instance and check for MySQL service status? It must return you `running`. Also you can try connecting to your DB via any of the SQL client. Try to `test connection`, it should return you `connected successfully`. For this you have to install SQL client in you laptop. You can follow (here)[https://medium.com/@ss.shawnshi/how-to-configure-and-remotely-connect-to-mysql-on-ec2-instance-cef164e8539] – CK__ Aug 21 '20 at 05:54
  • @ChandanKumar iam able to connect to my ec2 instance but problem is that i have lost my db password so how can i acces the database as u given the link?? – Mohit-Tech Aug 21 '20 at 06:21
  • 1
    Login into your EC2 instance and [try this](https://stackoverflow.com/questions/10070401/mysql-root-password-forgotten) – CK__ Aug 21 '20 at 06:35

2 Answers2

1

Here are the steps to be followed:

Locate the MySQL configuration file using: $ mysql --help | grep -A 1 "Default options"

On Ubuntu 16, the file location is typically /etc/mysql/mysql.conf.d/mysqld.cnf

Edit the configuration file using: $ sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

Add skip-grant-tables under [mysqld] block and save the changes.

2.

Restart MySQL service using: sudo service mysql restart

Check MySQL service status: sudo service mysql status

3.

Login to mysql with: $ mysql -u root

And change the root password:

mysql> FLUSH PRIVILEGES;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass';

Revert back the MySQL configuration file changes by removing skip-grant-tables line or commenting it with a # (hash).

Finally restart the MySQL service and you are good to go.

Mohit-Tech
  • 102
  • 7
0

I think the below method can help you out with your problem.

First thing you can do is go into your application(which you mentioned that is running well) and check the connection string, you would have used DNS name or DNS endpoint for the same, using that you can find that out.

  1. If it is DNS Name, then you can go and find in your hosted zone where it is mapped and the mapped DNS endpoint can tell you in which region and with which name it is launched in your AWS account.

  2. If it is using DNS endpoint then it can tell you in which region and with which name it is launched in your AWS account.

rksachin
  • 1
  • 4