Xampp Mysql and Apache not Working - How to backup database - mysql

I'm having trouble with my Mysql and Apache server here for a week already. Tried to look for every possible solutions in the internet like changing ports and everything. Still no luck. I would like to reinstall Xampp, the problem is, I have important databases which do not have any backups yet. Is there a way to backup these databases without having my apache and mysql started?

It depends a bit on the type of storage engines you're using.
MyIsam
MyISAM tables are stored as files, so it is easy to do a backup by copying files (*.frm, *.MYD, and *.MYI files). In a typical XAMPP installation they can be found under c:/your/path/to/xampp/mysql/data/ .
InnoDB
Have a look at the manual:
Copy all InnoDB data files (ibdata files and .ibd files) into a safe place.
Copy all the .frm files for InnoDB tables to a safe place.
Copy all InnoDB log files (ib_logfile files) to a safe place.
Copy your my.cnf configuration file or files to a safe place.
However, if you have important databases, it is advised to think about a backup strategy before problems occur. MySQL offers a variety of backup strategies from which you can choose the methods that best suit the requirements for your installation.

Yes, you can just copy the data files. for innodb you need the ibdata1 (or similar) file. For MyISAM you will see 3 files (different extensions) for each database and the filename match the database names. If it is MyISAM then you can just copy these files back into the data directory on your new install and it will just work.
The other thing you should do is not use WAMP! It is easy enough to set up from scratch and much easier to figure out when things don't work.... you just need to read a little bit.

Copy all the files in your htdocs to another location first, duplicate the database organizers from information envelope and erase xampp then re-install it. You also need to delete the ib_logfile0, ib_logfile1 files from the data folder inside mysql folder.
Read here for further procedure https://dba.stackexchange.com/questions/3437/lost-tables-in-drupal-site-database

Related

Transfer MySQL files directory from directory

What do I have to do to these files so that I can copy and paste the files into another program using only default windows functions? Copying and pasting it directly leads to an unstable database and the data within each table does not transfer.
As we answered in your other (nearly identical) question Export table from Xampp MySQL from file directory, this is not recommended and can lead to inconsistency. I could repeat here what I said there, but the answer is the same: if the MySQL service is stopped and if the entire datadir is copied and replaced, and if the MySQL versions are similar enough, then you might be able to accomplish this...but it's not supported and not recommended and you're much more likely to lose data than have success. File-level backups are not recommended for MySQL databases, you should export to an SQL file.

Where are my .myd, .myi and .frm files from my mysql database

I'm a beginner here and I can't seem to find the files. My professor wants me to send these files specifically to her, but when I "export data" from the workbench, it only generates .sql files. Where do I get the .myd, .myi and .frm files she's looking for.
Thank you
Don't worry about those. That's just how MySQL stores the data internally. If you read the documentation carefully you'll soon learn that you shouldn't depend on those files for backups anyway, they're likely to be in an inconsistent state if the server's running.
The best way to make a backup for small to medium-sized databases is the mysqldump command. There's a number of options that can be applied but the most important on a busy database is --single-transaction which produces a consistent point-in-time snapshot.
The SQL data you get from that, which can be saved to a .sql file, is sufficient to recreate the database and is a backup.
You can restore with the mysql command-line tool, or if you're not comfortable with that, the MySQL Workbench program.
Somewhere there is a data directory under a directory with MySQL in the filename, and under data is your own database directory. Files are in there. But if you haven't used MyISAM as the table format, the files will have different extensions, e.g. .idb for InnoDB.
You can find it via the query mentioned in #tadman's comment, or from a shell:
find / -name data -print
although you will probably get a number of matches.
You will have to stop the MySQL server before you can copy the files.

Can a mysql backup be transfer by copying and pasting data files from the mysql dir?

I need to reformat my computer and reinstall the OS. I have plenty of databases that are connected to sites running on my XAMPP stack. If I copy an paste the data files from the mysql folder into a new XAMPP stack, will the databases be preserved? If so, which files need to be copied? Are there other considerations? Also, is there a difference if the destination stack is LAMP or WAMP?
I strongly advice you don't try to backup/restore a MySQL database simply copying the files.
Although that can be done with MyISAM tables, InnoDB tables won't work simply by copying files.
If you need to move the databases from one instance to another, I recommend you use mysqldump to create database backups.
Sugested reads:
mysqldump - A database backup program
Using mysqldump for Backups
Copying MySQL tables, InnoDB tables not recognized (at dba.stackexchange)

Can i restore some mysql database by just copying folder in Mysql

I have seen that i have folders corresponding to the databases i have in
/var/lib/mysql/php_site1
Now i want to know that i copy that folder and just paste inside other mysql, will it work or i need to do anything else as well
provided i have same setting
It depends, I assume that you use InnoDB tables, when you shutdown your mysql instance you can backup the files, make sure it includes the following:
ibdata and *.ibd files
*.frm files
ib_log files
my.cnf files
On the new machine make sure you make the adjustments in the my.cnf which suits your database layout. If you are not absolutely sure what you are doing, i would suggest to use a simple dump to archive your goal. I have seen many times where people tried to copy the database and where left with a useless db.
Also please read this part of the documentation carefully: MySQL Docs

MySQL database disappear

I have done an idiot mistake, i cut the database folder in /var/lib/mysql folder and paste into my external hard drive because my hard disk was almost full.
Now i copy the database folder back into the original mysql folder, i cannot access the database anymore, phpmyadmin says it is an empty database.
Is there any way to recover the old database? If it disappear permanently it will be a big pain for me
What is the engine for your tables? InnoDB or MyISAM? If it is MyISAM then yes they can be recovered if you still have all the files but if type is InnoDB then there might be some trouble
And after pasting the files back to original directory you have to restart mysql server too.