I had an application that required a lot of resources, so I changed the instance type from t2.micro to t3a.small. However, I reverted back to t2.micro, and now all my MySQL databases are missing. I have never executed a DROP DATABASE
command.
Both the EBS volume and the EC2 instance are intact, and my other files are still present. However, when I access into MySQL, it shows that the databases have been completely reset.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| RECOVER_YOUR_DATA |
| mysql |
| performance_schema |
+--------------------+
Here are the contents of /var/lib/mysql:
[root@ip-172-31-38-89 ec2-user]# ls -al /var/lib/mysql
total 176144
drwxr-xr-x 5 mysql mysql 157 Jul 8 21:23 .
drwxr-xr-x 42 root root 4096 Apr 29 2021 ..
-rwxr-xr-x 1 mysql mysql 56 Mar 7 2021 auto.cnf
-rwxr-xr-x 1 mysql mysql 79691776 Jul 8 21:07 ibdata1
-rwxr-xr-x 1 mysql mysql 50331648 Jul 8 21:07 ib_logfile0
-rwxr-xr-x 1 mysql mysql 50331648 Mar 7 2021 ib_logfile1
drwxr-xr-x 2 mysql mysql 4096 Jul 8 14:33 mysql
srwxrwxrwx 1 mysql mysql 0 Jul 8 21:21 mysql.sock
drwxr-xr-x 2 mysql mysql 4096 Mar 7 2021 performance_schema
drwxr-xr-x 2 mysql mysql 78 Jul 8 13:05 RECOVER_YOUR_DATA
I had a database named spring which is now missing. This database contained important data. How can I recover it?
I also detached and reattached the EBS volume; could I have reattached it incorrectly?
[root@ip-172-31-38-89 spring]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 482M 0 482M 0% /dev
tmpfs 492M 0 492M 0% /dev/shm
tmpfs 492M 476K 492M 1% /run
tmpfs 492M 0 492M 0% /sys/fs/cgroup
/dev/xvda1 30G 21G 10G 67% /
tmpfs 99M 0 99M 0% /run/user/1000
I tried to replicate the issue by creating test
database and changing the instance type, but this time the test
database remained intact, so it seems that the instance type change is not the cause…
HyeonKyeong Park is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.