How to backup databases from Lampp folder? - mysql

Recently, my Xubuntu distro crashed. I wasn't trying to retrieve it. Rather get all the information that are required. I was trying to find database folders I ended up with getting some files whose extensions are frm ibd and opt in the following location : /opt/lampp/var/myqsl/database_name.
With a quick search, I have came up with "solution" (who knows if that actually works). That is, I have to copy the database folder and paste it to the exact same location (In another system, that's what I am planning). But I didn't see a solution like that in SO so, I am highly in doubt. And by installing a new distro, I won't have access to those files anymore.
FYI, I don't have access to anything rather than just files that exist in Xubuntu.

Related

Recovering MySQL data from external drive

AN older PC I was using has decided to give up completely but I've at least salvaged the HDD and mounted it on an external drive to the new Linux box (running Ubuntu Server 22.04). I'm trying to get the data off the old drive into the new installation so I can still work with the data on it. What's the easiest wary to get this done? (Me and MySQL have had many fallings out in the past!!) Thanks.
UPDATE
I've copied across a folder from within the old mysql folder to the new one but it isn't listed in the lists of databases. I tried to create it in mysql but it told me the schema directory already exists, so at least I'm in the right place.
SOLVED! Copied out the new mysql folder and swapped in the entire new one. As I wanted a clean install I then dumped the databases I wanted and swapped the original folder back before importing the dumped sql files. Phew!

How to access my MySQL files on a hard drive using Windows

I was given some research data on a hard drive. All the files are in one folder and consists of .frm files, .MYD files, .MYI files, .TRG files and .TRG files.
I downloaded and installed MAMP so that I can run an MySQL Server. I launched PHPMYAdmin in a browser and chose the import option. I then navigated to the data folder and realized that it was looking for a .zip file with the structure .sql.zip. I then proceeded to zip all of the content to comply and according to the WinZip dialog box, it was going to take 3 hours! This cannot be the correct action.
I found this solution from 8 years ago (derobert):
Recover Database Files From MYD MYI FRM Files
which has a linux solution (copy the files into the /var/lib/mysql/dbname directory)
There was also a solution for Windows in which a single .frm file and a ibdata1 file is copied to the data folder (alnel). Since my intention was not to copy the data to my notebook but, instead, read it directly from the drive, I tried another solution mentioned and it turned into a nightmare....
I created a symbolic link in the data folder: c:\MAMP\bin\mysql\data called mydata
c:\mklink /D mydata e:\MyResearchData
This created a link as expected. I then reloaded PHPMyAdmin expecting to see it listed. I did not. Recognizing that the /D switch is for a soft link, I tried a hard link using /H. However, that didn't over-write the previous link. I then proceeded to delete the link and it deleted all of my data! Recovery was not as simple as if I had deleted the data from the C:\ as it was not in the Recycle Bin. I was able to use file recovery software but now I am gun-shy about trying anything unproven.
I did eventually copy all the files into the MySQL data folder (suggested by Vishal)(c:\MAMP\bin\mysql\data\MyResearchData) and refreshed PHPMyAdmin ... no luck.
I'm hoping someone can lead me in the correct direction.
Thank you in advance!
You've figured out one possible way. The other way is to find My.ini (mysql config file) in which you will find datadir and basedir like
# Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.7/"
# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 5.7/Data
change the datadir to whatever location you have your MySQL data and restart your server. Since your current data dir is "c:\mamp\db\mysql" look for that line in the config file.
if you are going to use it often, i'd suggest installing MySQL server, workbench and mysql notifier using mysql installer for windows. It's much more easier to manage. With workbench you can do many things.

How to get MYSQL database from Xamp

I used xampp sometime ago to run mysql server. I forgot to save a copy of my database. Now my hard drive has crashed and I can only use it as external drive. Using it as an external hard drive I can access the xampp installation folder but I can't seem to find copies of mysql databases.
So this is what i tried:
But I found my database names in C:\xampp\mysql\data\voting
directory, where voting is a my database name. Now, in the voting
folder, I can find all my table names but they end in some wierd
extension (.frm or .ibd) that I cannot import to a new xampp that
I have installed. For instance there is a table in the voting
database called candidate .
My problems is that is there a way I can retrieve my database from the xampp installation folder?
If NOT, How can I get mysql database using xampp(Without sql,csv or json files)
NOTICE: The xampp directory is an old one and I cannot run it because it is on a hard drive that is slightly crashed and can be access externally to a computer.
After posting this for 3 days and getting no answer, i toiled and toiled until I got an answer.
What I did was I copied the data folder in C:\xampp\mysql directory where I installed xampp from my old xampp installation folder on my old hard drive.
I pasted the old data folder I copied into C:\xampp\mysql directory of my new hard drive.
NOTICE: there is an already existing data folder there, so I backed up before doing any changes.
Finally, I opened http://localhost/phpmyadmin/ in my browser and I can now see all my old MYSQL databases.

How to manually import database directly into the data folder in phpMyAdmin in XAMPP?

I recently installed a new version of XAMPP. I copied and pasted database folders from the old xampp's mysql/data to the same folder in the newer version. The database names are displayed in phpMyAdmin but it does not show any data.
I know I can do a simple import/export sql to resolve this but I'd like to know why copying and pasting the database folders not working? Do I have to do something else in order to make this work?
I'm going to backup my database regularly using an auto backup tool. Apart from backing up mysql/data folder, do I also need to backup some other folders or files to have a proper database backup?
why copying and pasting the database folders not working? >> as far as I know we need to use import feature, because it will register the database to mysql's infomation_schema.
So even if the database file is stored in the correct folder, it won't show up on the phpmyadmin because it's not registered. And I think mysql didn't do any directory scanning to determine it's database line up.
To back up automatically, there are several ways you can do. Moreover if you use linux OS, you have more freedom to do that, for example create a php script to backup your db and then execute it regulary by using cron job.
hope this can help you.

mysql - how do I load data from a different configuration

I'm not sure if this will make sense, but I'll give it a shot.
My hard drive went down and I had to reinstall the os along with all my webserver configuration,etc. I kept a backup of the mysql database, but it doesn't contain all the tables...I added a couple tables after my last backup.
I have access to the hard drive and the directory where the mysql data files are stored from the failed hard drive, but I don't know how to retrieve the data into my new mysql database. Is it even possible to get the raw data files from mysql and load them into a different instance? I'd even be happy if there was some way for phpmyadmin to show the data files, then I could dump out to a backup txt file, and reload them into my new configuration.
Any help will be appreciated. thanks.
well, bad news...I can't access the drive anymore. As I tried to copy the files the drive went totally down. So, I'll just redo the couple tables. Thanks for your help anyway.
Although not recommended or reliable, it is possible to simply copy the data without using mysqldump. It might help if MySQL was shut down in a controlled manner (which does not appear to be the case) and the source and target environments are as similar as possible in terms of lib and MySQL versions.
The datafiles should be compatible - you can copy the data directory to ubuntu, and edit the /etc/mysql/my.cnf to point to the new directory.
The only catch might be where ubuntu being case sensitive effects the tables.