0

We have one EC2 instance running our mysql database server.

due to a security incident we had to delete the current EC2 instance as database was completely messed up with some sort of encryption.

So we had to recover it from Snapshot/AMI that are being taken every 6 hours. we have past 1 months snapshots and AMI's available for this EC2 instance.

This EC2 instance has only one SSD (Persistent Block Storage) EBS volume, which is part of the Snapshots/AMI's.

We also have phpmyadmin installed but its not able to connect to DB for obvious reasons!

Below are the details of OS and the mysql Service status.

# cat /etc/release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

# mysqld --version

/usr/sbin/mysqld  Ver 8.0.22-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))

# systemctl status mysql.service

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (start) since Mon 2021-03-01 13:19:50 UTC; 241ms ago
    Process: 79728 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 79736 (mysqld)
     Status: "Server startup in progress"
      Tasks: 1 (limit: 1164)
     Memory: 91.3M
     CGroup: /system.slice/mysql.service
             └─79736 /usr/sbin/mysqld

Mar 01 13:19:50 ip-172-31-93-250 systemd[1]: Starting MySQL Community Server...
Mar 01 13:19:52 ip-172-31-93-250 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Mar 01 13:19:52 ip-172-31-93-250 systemd[1]: mysql.service: Failed with result 'exit-code'.
Mar 01 13:19:52 ip-172-31-93-250 systemd[1]: Failed to start MySQL Community Server.
Mar 01 13:19:53 ip-172-31-93-250 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 328.
Mar 01 13:19:53 ip-172-31-93-250 systemd[1]: Stopped MySQL Community Server.
Mar 01 13:19:53 ip-172-31-93-250 systemd[1]: Starting MySQL Community Server...

# journalctl -xe

Mar 01 13:14:20 ip-XXX-XXX-XXX-XXX systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit mysql.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Mar 01 13:14:20 ip-XXX-XXX-XXX-XXX systemd[1]: mysql.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mysql.service has entered the 'failed' state with result 'exit-code'.
Mar 01 13:14:20 ip-XXX-XXX-XXX-XXX systemd[1]: Failed to start MySQL Community Server.
-- Subject: A start job for unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 105083 and the job result is failed.
Mar 01 13:14:21 ip-XXX-XXX-XXX-XXX systemd[1]: mysql.service: Scheduled restart job, restart counter is at 206.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Mar 01 13:14:21 ip-XXX-XXX-XXX-XXX systemd[1]: Stopped MySQL Community Server.
-- Subject: A stop job for unit mysql.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit mysql.service has finished.
--
-- The job identifier is 105149 and the job result is done.
Mar 01 13:14:21 ip-XXX-XXX-XXX-XXX systemd[1]: Starting MySQL Community Server...
-- Subject: A start job for unit mysql.service has begun execution
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has begun execution.
--
-- The job identifier is 105149.

For additional Log output of "# tail -500 /var/log/mysql/error.log"

Can any of you please help me restore the mysql service with the data/databases?

We are not sure what is the right procedure to follow in this scenario to restore the databases.

Thanks in advance!

1
  • 1
    You have lots of errors stating: "Can't start server: Bind on TCP/IP port: Cannot assign requested address" which means that something else is already running on the IP and port you are binding MySQL to. This would normally happen if you already have a MySQL process running on the requested IP and port. Mar 1, 2021 at 19:01

1 Answer 1

0

To resolve this issue the only thing you have to do is below:

just edit /etc/mysql/mysql.conf.d/mysqld.cnf file using whichever editor you like and update the bind address using whichever editor you like. below is the line you need to update with the correct/updated IP address. because when you launch a new EC2 instance using an backup AMI image or Snapshot it gets a new private IP Address (Unless you have made it static in your OS configuration earlier.)

bind-address = 192.168.XXX.XXX

Then restart the mysql service using below command and everything will start working as earlier including the PHP My Admin console.

systemctl restart mysql.service

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .