Recovering MySQl database from .frm, ibdata and ib_logfile - mysql

I have .frm, ibdata and ib_logfile from my previous version of MySQl and now I have shifting to a newer version. Unfortunately, I donot have the previous version installed so I cannot take the dump and import into the new MySQl version.
Please suggest some way to get these databases running in the newer MySQL version. I have all the required files from the previous MSQl.

It's really dangerous to do this, so just do it on a copy of the files (and try hard to use the exact same version of MySQL):
Make sure the MySQL service is not running
Remove the ib_logfile (it is not needed)
Put the files in place in the MySQL datadir
Start your server and check the logfiles.
Check that everything is working.

Well, it may seem trivial. But since I had saved the entire MySQL folder present in Program Files from my previous installation. I found out that I could still use that folder to run the previous MySQL installation without any changes or reinstallation (it seems MySQl works like Linux softwares). And now I am using mysqldump to create the dump and then will import it into the new MySQL version.

Related

MySQL restore table from XAMPP issue

I used to rely on XAMPP in my Kubuntu 18.04 which located in /opt/lampp. I uninstalled the XAMPP and had a whole folder backup in this directory before that, and eager to install all the LAMP stack individually, which i installed apache2, mysql-server, and phpmyadmin after that.
The thing is, i want to import my databases from my backed up XAMPP folder located in /opt/lampp/var/mysql which consist of all my databases with tables in .frm and .ibd format, which is obviously exist, to my current installed mysql package database location in /var/lib/mysql.
After i moved those databases, i opened phpmyadmin to make sure the dbs imported correctly, but i only saw the database without the table inside the database. How come? What needs to be done to restore the tables inside?
You can't just copy database files from the datadir (/var/lib/mysql in your case). A proper MySQL/MariaDB backup is to generate .sql files which you can then import independently. It's not possible to selectively restore certain databases, due to the way certain files are managed (such as ibdata1 and perhaps others such as logfiles).
What I would try, and may or may not work, is this (the usual disclaimers about backups apply, I'm not responsible if your system becomes inoperative or catches fire, etc):
Make a back up of your existing databases (to SQL, I use the mysqldump command-line utility that ships with MySQL/MariaDB).
Stop the MySQL daemon and make sure it isn't running.
Temporarily move your current datadir out of the way (perhaps with a command like mv /var/lib/mysql /var/lib/mysql-current).
Copy your complete backup, the entire MySQL datadir (from XAMPP's old /opt/lampp/var/mysql), to /var/lib/mysql.
Start the MySQL daemon.
Connect and export any data you wish to save to SQL files.
Stop the daemon.
Move the current /var/lib/mysql out of the way (or if you're brave, delete it entirely).
Restore your original files from /var/lib/mysql-current to the original location in /varlib/mysql
Start the daemon again
Import the SQL files you've generated from step 6.
That's it — you should now be all set with your original data in your new database.

How to restore MYSQL database after installing a different version of WAMP?

I would like to know How to restore MYSQL database after installing a different version of Wampserver. The explanation is as below:
I deleted the wampserver folder accidentally and I lost my MYSQL database. However, I have succeeded to restore the data folder that contains the database and I have installed another version of Wampserver (Actually, the old version of MYSQL that I was using was 5.5.8 , and the MYSQL version that I am using right now is 5.6.17) and I have tried to restore the database by copying its folder and putting it and the old ibdata1 file under the data folder of the new installation. But, unfortenately, that doesn't work.
So, my questions are:
Is it possible to restore MYSQL database after installing a different version of Wampserver (with a different version of MYSQL)?
If yes, how can I do that? What would be the solution?
In the past when this has happened to me, the only option that worked was to reinstall an older version of WAMP (i.e. MySQL) to match what my databases were created in originally.
If you install the same WAMP again, copying the folder should work now.
If you can gain access to your databases at this point, then you can do a proper backup of them using phpmyadmin or mysqldump etc.
After you get a proper backup, remove the older WAMP version and install the latest version again. Now you have to restore the databases using the backup files in order to put them into the newer MySQL version.
If you backed up your database you can restore it using your backup file. If you are using a graphical interface for mysql like PHPMyAdmin there is a import button you can use to import your .sql, .csv, .zip, or what ever extension you used to backup your database.

XAMPP NOT WORKING! - OS X Yosemite

I was working with XAMPP 1.8.3-3 on OS X Mavericks. After upgrading to Yosemite Mysql server stopped working. And an upgrade to XAMPP 1.8.3-5 fixed the problem and mysql server starts working.
Now the entire database list is showing on phpmyadmin, but no access to the tables. Its showing “#1146 - Table ‘DB_NAME.TABLE_NAME’ doesn’t exist”.
Unfortunately I don't have any DB backup!
I have the entire XAMPP folder backup. So how I can able to retrieve the mysql tables?
just type /Applications/XAMPP/xamppfiles/bin/mysql.server start
in terminal then start xampp
you can restore if you have all the mysql folders from XAMPP folder. (check /XAMPP/xamppfiles/var/mysql in backup)
if you have var/mysql folder, open and look for database names you had earlier.
there is a separate folder for each database you had earlier. open the folder and it will contain lots of files with table names.
if your old table engine is InnoDB you will see 2 files. with .frm and .ibd extensions.
or if you had MyISM it will contain three file per table which has .frm, .MYD and .MYI extensions.
after you verify you have all the required files in backup, you can start restoring them.
stop mysql
copy required database folder completely and paste it to currently installed folder. (/Applications/XAMPP/xamppfiles/var/mysql/)
start mysql
to restore web files, open htdocs folder in backup and copy required site folder to currentely xampp installed htdocs folder.
This solution worked for me. Good Luck !
Do a clean install. See my answer for my own question. xampp mysql server not starting. The bad part is that I'm not sure if it will save your database the way I explained. What you might try is going to xampp > xamppfiles > var > mysql > 'your database name' and making a copy of the database folder on your desktop and moving it back once you reinstall it. I tried and I think it might have worked had I changed the file permissions. You can also try experimenting to see if it preserves the database if you do this. I would do some serious testing if you really want to save your database before doing this.

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".