What is the exact location of MySQL database tables in XAMPP folder? - mysql

I have a MySQL database and I want to know the exact location where this data actually stored in the XAMPP folder, I went to this file location to try to get the information:
xampp -> mysql -> data ->
Here I found a separate folder for each of my databases and within these folders I saw files stored with the .frm format (FRM FILE).
When I copied my desired database with all tables in .frm format and try to use them on another PC, I was given an empty database of the same name.
Where are the data files for the database kept on the local server?

For Mac, your database files are located at:
/Applications/XAMPP/xamppfiles/var/mysql
You might need admin permissions to access or delete your files.

Your database is in this directory:
C:\xampp\mysql\data

Rather late I know, but you can use SELECT ##datadir to get the information.
Happy file huntin' SO community :)
This is how it looks when ran in phpmyadmin:

I think the matter is your tables engine. I guess you are using InnoDB for your table. So you can not copy files easily to make a copy.
Take a look at these links:
http://dev.mysql.com/doc/refman/5.0/en/innodb-backup.html
http://dev.mysql.com/doc/refman/5.0/en/innodb-migration.html
Also I recommend you to use something like phpMyAdmin for creating your backup file and then restore the backup file on the next machine using the same IDE.

Copy and paste the entire data folder, not just the content.
I use xampp, and the path to the data is xampp/mysql/data.

The exact location is stored in "my.ini" which exists under main mysql installation directory. In my.ini file, look for 'datadir'. This parameter points the data folder.

Data are store in this path. You can search data location, just put the below address in your search location (url address):
C:\xampp\mysql\data

Just in case you forgot or avoided to copy through PHPMYADMIN export feature..
Procedure: You can manually copy: Procedure For MAC OS, for latest versions of XAMPP
Location : Find the database folders here /Users/XXXXUSER/XAMPP/xamppfiles/var/mysql..
Solution: Copy the entire folder with database names into your new xampp in similar folder.

If you are like me, and manually installed your webserver without using Xampp or some other installer,
Your data is probably stored at C:\ProgramData\MySQL\MySQL Server 5.6\data

In Ubuntu the file path is ./opt/lampp/var/mysql

Related

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.

Restore DB data after XAMPP uninstallation

I uninstalled XAMPP from my pc, during the uninstallation the system asked me if wanted to delete htdocs folder (I selected "yes" because I made a backup of this folder before the uninstallation), after that the system asked me if I wanted to delete Mysql data and I selected "NO".
After the uninstallation I had still some folder in C:/xampp (also mysql folder).
Now I reinstalled XAMPP but is there a method to restore DB file with the folders that I have?
I tried to replace the mysql folder but it wasn't a good idea.
This is a screenshot of the folders that are remained after the uninstallation:
The databases are stored on xampp\mysql\data location on this location you find the folder for each database in this folder you have file db.opt and also two file for each table that is (yourtableName.frm and yourtableName.ibd)
something like....
if you put that all dbfolder (in mycase i.e. "empdb") in to above location you will get your database back to used
Hope it make sense

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.

Attaching an existing database with MySQL

Disclaimer: I have never used MySQL before!
I have a folder containing a number of .frm, .myd and .myi files that I believe are a MySQL database. I have pulled these files from a defunct server for a client who has not used the server or database for some years but is now looking to resurect some of the data for a new venture.
I have downloaded the latest free edition of MySQL, along with MySQL Workbench and am looking to connecct the existing database to the new installation; the equivalent to an "Attach" if I were using MS SQL Server.
I have found a few articles that say if I simply copy the folder into the data folder for MySQL and restart the service the database will show up. I have tried this (using both the data folder within the installation folder and also the "MySQL Datafiles" folder created during the intial configuration but when I restart the service nothing shows up.
How should I go about attaching this database?
Ok. I found the answer, the folder I was adding the database to was the wrong one.
Though I had found 2 "data" folders, there was a 3rd hiding in C:\ApplicationData; once I added my data files in here and restarted the MySQL service I could see the data.
On Windows 8 the default folder where MySql databases are stored is:
C:\ProgramData\MySQL\MySQL Server 5.6\data
5.6 is the version.
Please note it is ProgramData not Program Files which is easy to overlook.
Copying there and restarting the service worked fine for me. I'm even copying the DBs from an earlier 5.X version.

How to restore MySQL database from WAMP?

Last month I had to reinstall Windows and I've moved the WAMP folder to another partition. Now I've installed WAMP again but I need the old database. How can I take the old MySQL database from the saved WAMP folder on the safe partion?
In the wamp/bin/mysql/../data/ I have my old databases. If I copy the database folder only, in phpMyAdmin I can't see all the tables/views from the old database.
Looks like you use InnoDB tables, so you should also copy ib* files in data folder (but this will overwrite any InnoDB table created in new installation.)
Alternatively (even better) you may set 'datadir' parameter in configuration file and specify path to data folder in old installation.
When you're doing changes to MySQL server at the back side (i.e. not using standard MySQL commands or interfaces), remember to stop the server before any changes and start after doing the changes.
Anyway this is not the recommended practice, use mysqldump instead to take regular backups and you can later restore a dump file using mysql ... < dump-file.sql.
Goto old wamp like wamp\bin\mysql\mysql5.5.24\data folder and copy all content and paste or replace with new setup folder "wamp\bin\mysql\mysql5.5.24\data".