Search code examples
mysqlsqlinnodb

how to restore mysql innoDb databases from programData file


I have reinstalled mysql. I already backed up mysql data in programData folder. Now I want to restore all the databases from that file. I don't want to mess around and try things for it. Do I have just to copy the backed up file into my new mysql Data folder? I have copied my database file(containing .frm and .ibd files) along with ib* files but after that my server didn't start again. I don't have deep understanding of what is going on back there. Please let me know how to do that correctly.

I am using mysql 5.7 version


Solution

  • The problem turned out to be the file ownership and permissions.

    Files under the MySQL datadir must be readable and writeable by the uid of the mysqld process. This is typically a uid "mysql" (since everyone agreed years ago that running daemons as root is not a good idea). There is also a gid "mysql" on default installations.

    The fix is therefore:

    chown -R mysql:mysql <datadir>