restore specific database from mysql full .sql backup - mysql

I have a full back up from my all mysql databases, the problem is that my backup contain default mysql, performance_schema and information_schema databases that prevent me from restoring my backup.
the question is how i cant remove this default databases from my full backup?
i try to edit .sql backup file and delete create and insert for this database, but its make some problem on miss deleting injections.
is there a visual software that i open my .sql file with that and it show me a databases and the tables and i select some database to delet them ..?????!!!
please help me, my databases are very important ...
*I want something to virtualize my databases and i delete unwanted database from it and save as the result *

What about doing the following steps:
rename default databases in your .sql files
restore your backup
delete restored renamed databases

Related

I Want to use a mysql database from a backup of a non-working server on a new computer

My database is from a backup of the non-working server.
My database is the teachercenter folder that was on the server, and contains files for each table name with the extension *.frm.
I copied the database from:
C:\Users\xxx\Downloads\wamp-saved\wamp\bin\mysql\mysql5.1.36\data\
And pasted that folder on my computer here:
C:\wamp\bin\mysql\mysql5.6.17\data
I realize the the two mysql's were different versions, but I'm just trying to use the database files.
When I start up PHPMyAdmin on the new computer, it shows the teachercenter database in the list of databases.
Also, if I click the plus next to the teachercenter database, I can see a list of my database tables!
But if I click on teachercenter database itself, I get error:
No tables found in database.
How do I get mysql to recognize and let me operate (PHPMyAdmin) on the teachercenter database on the new computer?
I tried to start/use wampmanager.exe, but I don't see it running to use it's menus.
THE PROBLEM IS SOLVED:
At: stackoverflow.com/questions/10934745/… a simple answer to my probelem is given, as follows: "Yes this is possible. It is not enough you just copy the .frm files to the to the database folder but you also need to copy the ib_logfiles and ibdata file into your data folder." I copied the ib_logfiles and ibdata file into my data folder, and Voila! PHPMyAdmin was completely happy with the database and its tables and I could do SQL exports of table records.
Summary: To make use of a MySQL database of *.frm files that your MySQL doesn't understand, simply copy the ib_logfiles and ibdata file from whereever you got the .frm files from, and put these two files in the data folder next to the database you want to use. Once you do that, the MySQL database engine will recognize your database, and you can all PHPMyAdmin operations on your fully operational database.
Because you can't be sure that the MyISAM storage format backwards compatible, your safest option is to install MySql 5.1.36, use mysqldump to export your entire database to plain SQL, install MySql 5.6.17 and then import your data using SQL.
Also, this probably gives better results because your indexes are rebuild.

how to restore particular database from .sql file

I did mysqldump for --all-databases and after some software updation on my machine the one database has deleted. so, How to restore that particular database form .sql file?
.sql file contain mysqump for all database.
pleased suggest something
When I've done this in the past I've used Workbench.
The SQL should contain the code to re-create the schemas and tables, along with the data.

MySQL Phantom tables

I did a drop query on a MySQL table... my GUI interface crashed right in the middle of the process. The table does not exist in the listing; however, when I go to make a new one it says that there is already a table with that name. I tried doing a DROP TABLE and a RENAME on this phantom table but both queries run endlessly.
FYI I am unable to restart MySQL because shit might break on our live sites.
Any help is greatly appreciated.
Try repairing the table :
http://dev.mysql.com/doc/refman/5.1/en/repair-table.html
The tablename matches three files in the filesystem with a .frm, .myd and .myi extension (for the table definition, data and index files respectively) One of these files is corrupted, which prevents MySQL from carrying out your order.
Option 1 delete files from the filesystem
Have a look at the filesystem to see which file still exists.
If the .frm file is missing, you should be able to delete the other two files.
If the .frm file is still there do not delete, MySQL still has a lock on that file.
Option 2 repair the database
Use the myisamchk to diagnose and repair your database.
See: http://forge.mysql.com/wiki/MySQL_Internals_File_Formats
And: http://dev.mysql.com/doc/refman/5.0/en/myisam-repair.html
Check the directory where mysql stores the databases. On Ubuntu it's in /var/lib/mysql, but it may be different depending on your OS and configuration. Inside that directory there is a directory for every database, go into the directory for the problematic database, and delete any file that are the table name with extensions .frm, .myd, and .myi.
Sounds like you have a disconnect between what you have and what your server thinks you have.
You'll need SSH access and have to repair the table manually.
Log in to SSH and type:
mysql -u root -p
And enter your root mysql password.
Then
show databases
And it will list all the databases on your server.
Select the database you want with
use databasename;
Then
show tables;
This should list every table in your database. It's likely that it's still shows up there, so do a
drop tablename;
Hopefully that will correct your issue.
Ended up restoring from a backup... editing files in the file system is scary and may have required a restart.

Backup Mysql Databases

I wanna reinstall windows on my PC i wanna backup my Databases in MySQL. I have around 30 plus databases. is there an easy way to back up the content and restore it later ?
You can use mysqldump -A to do generate sql dumps for all databases.
Reference: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
Alternatively, you can also just copy the acutal data directory.
Edit: apologies for not being specific, as others have noted this will work only ISAM. For innodb, you'll need to backup using mysqldump or another utility such as phpMyAdmin.
Use mysqldump to create a database dump of each database. You can later easily recreate the databases from these dumps by running them through mysql. This would be the most generic answer, knowing nothing more of your set-up.
If your databases contains MyISAM tables, then you could just copy the files. Otherwise (using INNODB) this doesn't work.
I assum you don't have the binary log activated, you should use mysqldump.
Take a look at: http://dev.mysql.com/doc/refman/5.1/en/backup-methods.html
You could try with PHPMyADMIN if you don't feel confortable with mysqldump.
go to phpmyadmin and export all the database.. After installing wamp in ur new pc.. go to import and import the files you've exported previously..
Have you given the GUI tools a try?
http://dev.mysql.com/downloads/gui-tools/5.0.html
Have a look at the "Backup" option in the MySQL Administrator. The "Restore" option might also be helpful after the backup is done. :-)
Allows you to backup a single db or all db's at once.
You can use SQLyog MySQL GUI to backup your database. It has scheduled backup(you can export data into a single file or as multiple files) and backup as SQL dump(The dump will contain SQL statements to create the table and/or populate the table) to take backup and can restore those .SQL files using Execute SQL script tool.
try the tool here.

How can I recover MySQL tables from data files?

I've got a database (all MyISAM tables) and the machine where MySQL was running is no longer bootable. However, we have all the MySQL data files from the data directory. How can I restore the data from the MYD and FRM files, or whatever other files I should be looking at in the data directory?
I've been doing some searching on this and it sounds like for MyISAM I should just be able to copy the database subdirectory from the old MySQL data directory to the new MySQL data directory. However, that's not working for me. A database with the name of the database I'm trying to recover shows up in the list of databases in phpMyAdmin, but all the tables show "in use" and have no information (e.g., number of rows, number of bytes, column information, etc.). Any operation on those tables (e.g., SELECT * FROM {table}, REPAIR {table}, CHECK {table}) returns a "no such table" error.
One of the tools I ran across in my search is DBACentral by MicroOLAP. It's got component that's supposed to restore data from FRM/MYD files, but when I tried to run it, it didn't list any tables that it could recover from my FRM/MYD files.
This is on a developer workstation that's running Vista Business 32bit. MySQL version is 5.0.27. After fixing the machine, I went and got the exact same version of MySQL (v5.0.27), thinking that if I'm just going to drop in the binary data files I should do it with the same version of MySQL. It still didn't work.
Any insights would be greatly appreciated... thanks!
-Josh
Install the same version of mysql.
Remove mysql directory from data directory of the server and copy it from the crashed server. This is the key element
copy directory of database you want to recover into data directory of new server
start mysql.
switch to mysql database: USE mysql; and run REPAIR TABLE <table name> on every table.
Do the same with database you want to recover
tip: make sure the 2 directories have the same permissions like data directory
If you did not save mysql database (mysql directory in your old server's data dir, then you can try to:
create database with the same name as database you want to recover.
Then you can create each table (it would be good to use the same structure - you'd have bigger chance of recovery).
then stop mysql server and delete files from database directory and overwrite them with files from old server
start mysql and repair each table.
I wound up giving up. I think the answer is that, with my particular version of MySQL, this doesn't work. Hopefully things have improved since then.