How to recover Mysql database from backup files - mysql

I have using VPS that had to be re-imaged. my DB was part of it and it was being backup up as the app wasn't in production yet. However, there is some data that I wish to recover on it. the VPS provider is giving me a backup of the image (Ubunto Linux) that has all the files.
Is there a way I can recover my data?

The mysql data files in Ubuntu are located at /var/lib/mysql
To restore your database you need:
1) create new database named as old one
2) stop mysql server
3) copy old database files from /var/lib/mysql/your_database_name/ to new system
4) start mysql server
Your database will be restored.

Related

How to restore database files after update mysql

I'm using laragon for my project, today (unfortunately) y has a problem with my SSD (C:) and I have to format all, my project was located is D:\ but MySql was not working, I updated from MySql 5.7.24 to 8.0.23
before doing that, I have saved database files and old MySQL files, now I don't have my database, my localhost is empty
I have files in .frm, .ibd from the database (my tables) and I have my old MySQL files (.MYI, .MYD, .frm, .ibd, etc)
How can I restore my database in mySQL-8?
Your question is not clear. However, you can:
Back to MySQL 5.7.24
Dump your database to a sql file
Switch to MySQL 8
Restore from the dumped sql file
Note: If you have no purpose to upgrade, you should go with MySQL 5.7

Migrating data from older mysql installation to new one in mac

I had mysql version 5.7.12 in my macOS High Siera full of database files stored in /usr/local/mysql-5.7.12-osx10.11-x86_64/data directory. Then I updated mysql to 5.7.23 and a new directory is created as /usr/local/mysql-5.7.23-macos10.13-x86_64/data in which the upgraded mysql expects the database files to reside. Can I simply copy the database files from the older directory to this one and restore my data? I don't want to export the databases and import them back.
Here is how I did it.
Stopped mysql
Copied all the database file/directories and a file called ibdata1 (the tablespace for InnoDB) from the older data directory (/usr/local/mysql-5.7.12-osx10.11-x86_64/data) to the new one (/usr/local/mysql-5.7.23-macos10.13-x86_64/data).
Granted necessary privileges to database users.
Started mysql and everything comes back.
[P.S. I need to do this because the database files are multiple tens of GB in size and I don't have the necessary disk space to backup and restore.]

Restore SQL database for WordPress

Unfortunately my VPS got corrupted and therefore I wasn't able to perform an export of the sql database with phpmyadmin. I do managed to copy all the SQL files .frm, .idb, .opt etc
Is it possible to recover the database and make my wordpress site working again?
Im using centos7 with Plesk Onyx / phpmyadmin
Absolutely! First get a new instance of your VPS running and create your database again, after created copy the .idb(innodb) or .myi/.myd(mysami) files right back where you found them
Each table comes with a .frm, don't forget those, as well as a db.opt for the database
Typical mysql storage (on linux) is located:
/var/lib/mysql/database_name
Once copied over restart mysql and check again

changed ownership on mysql files. How can I recover database?

I am using digitalocean VPS. Accidentally I changed all files' ownership to www-data on my server. How can I get my mysql database copy from this server?
No backups? MySQL files should be in /var/lib/mysql or /var/db/mysql... look around, you may be able to change the ownership of those files and get mysql to start again, dump the db and start anew on another machine.
I created a new vps with digitalocean and installed mysql.
Then copied file permissions and owners from new vps to old vps.
Mysql worked again on old machine!

Migrating MySQL databases from files only

On a fresh install of MySQL on Mavericks (via Homebrew if that matters) how can I take database files from a back up and migrate them to /usr/local/var/mysql in the new instance? I have a directory for each database and one huge ibdata1 file.
If I move them by a simple file transfer, start the new instance and log in, each database is there however no data is present when I check a table.
it should work if keeping or upgrading server version. Make sure ownership and permissions are correct. Then run mysql_upgrade which will adjust the files.