Dealing with server issues can be nerve-wracking, especially when critical databases like MariaDB are at risk. Recently, I faced a challenging situation where my server was unbootable, and the MariaDB root password was forgotten. With persistence and strategic troubleshooting, I managed to rescue the database, back it up, and migrate it to a new server. Here’s a detailed account of how I achieved this feat, ensuring no data loss along the way.
The Problem:
Steps to Recovery:
1. Accessing the Server in Rescue Mode
"mount /dev/vda1 /mnt chroot /mnt "
MariaDB wasn’t running, and the typical service commands were unavailable in rescue mode. To manually start MariaDB:
- Locate the MariaDB data directory.
- Start the service directly using
mysqld_safe
.
Without the root password, accessing the database was impossible. I reset the MariaDB root password as follows:
- Start MariaDB in skip-grant-tables mode:
Open the MySQL shell:
- Reset the root password:
4. Dumping the Database
mysqldump
command to create a backup:5. Transferring the Backup to a Remote Server
To migrate the backup to a new server, I used scp
:
scp database_name.sql user@remote_server:/path/to/destination
6. Restoring the Database on the New Server
mysql
command:- Always Keep Backups: Regular database backups could save hours of troubleshooting.
- Master Rescue Mode: Understanding how to navigate rescue mode is critical for disaster recovery.
- Document Every Step: Documenting fixes ensures smoother recovery if the issue reoccurs.
Server failures can feel overwhelming, but with a methodical approach, even complex problems can be resolved. By following these steps, I not only rescued my MariaDB database but also learned valuable lessons about troubleshooting and server management.
If you’re facing a similar issue, don’t panic. Stick to the process, and you’ll come out stronger on the other side.
0 comments:
Post a Comment