Results 1 to 5 of 5

Thread: Restore mysql databases from files

  1. #1
    Join Date
    Sep 2015
    Location
    Italia
    Beans
    136
    Distro
    Ubuntu 18.04 Bionic Beaver

    Restore mysql databases from files

    Hi everyone,

    a few days ago I lost my server. The motherboard no longer worked, but the hdd worked normally. The old server was ubuntu 16.04.

    So I installed ubuntu 22.04 server on a new computer, and I want to restore mysql databases from /etc/mysql folder.

    Is there a way?

    Thanks

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Restore mysql databases from files

    /etc/mysql is just for MySQL settings. The actual DBMS files are under /var/llib/mysql (usually). BTW, there have been huge mySQL changes over the years, so you'll need to look up the migration steps to get from the version you had to the version you will be running. That's what release notes are all about. READ THEM!

    With the release of 24.04 yesterday, people will begin practicing the production server migrations from 22.04 to 24.04 ... practicing ... since they don't want any data corruption or data loss, but going back to 16.04 is so long ago that most of us have forgotten any issues. Heck, we stopped using MySQL and switched to MariaDB sometime between 2026 and 2018, so there are other migrations you may want to consider.

    Today, the default DBMS is MariaDB and MySQL is deprecated for a number of years on Ubuntu.

    Sometimes the best method is to perform a mysqldump to get text files for the entire DB, then restore them into a new system with a new DBMS engine.

  3. #3
    Join Date
    Sep 2015
    Location
    Italia
    Beans
    136
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Restore mysql databases from files

    I also have the folder /var/llb/mysql.

    All the tables have three files: frm, myd and myi.

    Is there a way to restore the tables?

    Thanks

  4. #4
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Restore mysql databases from files

    A way? Yes.

    Install 16.04 somewhere, place the DB on that system in the expected location, open the DB using normal DBMS commands, then use mysqldump to create a backup for everything in the DB. All tables, views, triggers, constraints, external functions, everything. Take that dump to the new system and use the opposite of mysqldump to recreate the DB under the new OS.

    It might be easiest to create a virtual machine with 16.04 on the new hardware. It doesn't need to be a huge VM, just large enough to run the DB for 1 user and do the mysqldump.

    https://linuxize.com/post/how-to-bac...ith-mysqldump/ shows how to backup and restore.
    MySQL 5.x --> 8.x migration: https://dba.stackexchange.com/questi...-via-mysqldump
    Google will find lots of examples, if you need others.

  5. #5
    Join Date
    Sep 2015
    Location
    Italia
    Beans
    136
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Restore mysql databases from files

    So I created a VM with ubuntu 16.04, installed via tasksel the lamp server.

    Now, I only have to copy the files in the folder? Or is there some other to do?

    Thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •