percona backup and restore - mysql

I'm trying to use percona xtrabackup to backup a mysql database. in the restoring the database according to the documentation:
rsync -avrP /data/backup/ /var/lib/mysql/
this will copy the ibdata1 as well.
what if I have want to restore the backup into an existing mysql instance with some some existing databases? would this corrupt my other databases? clearly this will overwrite existing ibdata1.

I suppose you have a local http/php server, so in case you don't need to batch import or export information, I suggest you use a database manager app that can import or export as sql, csv or tsv files.
I use a web-based admin tool called Adminer and it works great (plus, it's just a single php file). It has options to export or import a whole database or just certain tables and even specific registers. Its usage is pretty straightforward.

Related

How to import large database into local database

I'm going to import the database from serve to my local.
Dumped file's size is 5GB.
How can I export and import database quickly?
Oxymoron: "quickly" versus "shoveling 5GB around".
If not already dumped:
mysqldump --opt ... | mysql ...
Depending on where you execute that pipe, one or the other would have -h to refer to the other machine.
If already dumped via mysqldump to, say, db.dump, then
mysql ... < db.dump
A simple dump using mysqldump will create a text file with instructions to recreate the database. This process is slow, lock tables and usually results in a large file.
If you need to backup and restore large databases I recommend to take a look at Percona XtraBackup.
XtraBackup works by copying the database files directly from the MySql folder, which results in data that is internally inconsistent, but then it performs crash recovery on the files to make them a consistent, usable database again.

Efficient ways/ tools for mysql db cloning

I have an ERP that is requesting instances of e-commerce to be created.
These instances are basically clones of the master on a same server.
So I have master DB (currently a dump file) and master code gz.
Through various scripts clone is created and installed.
Everything else is fast except db import from dump.
Plus when there is a request for, say, 50 instances simultaneously, it isn't realistic to import all these databases.
The question is:
Is there any other efficient tool to import a database other then mysql db < file.sql?
Any binary formats?
The only solution I can think about is to use a script to create 100 db clones in advance one buy one, and then when 50 new db's are requested, just rename existing clones.
You can recreate the database on the fly without exporting to a file and importing back, this will eliminate parsing a .SQL dump file back to mysql:
mysqldbcopy --source=root:root#localhost \
--destination=root:root#localhost world:world_clone
https://dev.mysql.com/doc/mysql-utilities/1.5/en/utils-task-clone-db.html

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 import table data MySQL?

I had a problem with MySQL on one of my DigitalOcean Ubuntu servers, so I compressed the files and have transferred them over to a new one.
I have moved the /var/lib/mysql folder over, which has the databases in, they are now visible in phpMyAdmin, but when I click them it says the table doesn't exist, do I need to run a command to import it all, or should I start again and import it differently?
This depends on the storage engine you use on your source System. If you use MyISAM you can just copy the three file associated with your table (.frm, .MYD, .MYI) to your target machine, restart the MySQL Service and your tables are there. With all other storage engines you should use mysqldump from a comandline (see here).

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.