Backup Mysql Databases - mysql

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.

Related

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)

copy and create new mysql setup on server

Iam a newbie for DB. I have a running database on godaddy's mysql setup. Now i have a new server whose access is not with me. I have to make a file which can install and create new mysql on that server plus it can copy and store specific tables from my current server database too.
I have to give this file to the person who is having the access so that he can execute it and can have all the content. How can i make such a file?
You can use MySQL's mysqldump to take backup of your databases.
Alternatively, You can always backup your database using MySQL GUI tools like SQLyog.
I guess GoDaddy do not allows direct connection for mysqldump to work. In that case you can use SQLyog's HTTP tunneling capability.
Give the generated backup file (created through SQLyog or through mysqldump) to the person who has access and he will upload the file.
Here is the SQLyog's documentation for taking Backup. Select Databases and Tables that you want to backup through wizard.
Hope it helps....

How to recover a particular database from MySQL dump file?

I was having a website at a hosting while taking the backup I took the backup of whole mysql by mistake which includes databases of all my other websites also.
So now the problem is I want to extract that particular database from complete sql file?
Is there any procedure to do it or can we import that complete dump file into a mysql. So that later I can export that particular database after importing it to MySQL.
Please help me or suggest me how to do it.
Thank You.
http://fragments.turtlemeat.com/mysql-database-backup-restore-phpmyadmin.php
This should help.
If the size of the schemas in your backup file that you do not want to restore are not that big and there aren't that many other schemas in there, your best bet would probably be to just restore the entire backup and then do a backup of just your schema. One easy way to backup just your schema is to use MySQL Workbench. If you run into problems getting setup or doing the backup you might want to check this little write up that walks you through installation and performing a backup.

MySQL (5.x) database backup/restore to file tool

Welcome,
I'm looking for php class what allow me to backup MySQL (5.x) databases under PHP.
I test many from phpclasses but most all are written for mysql 4 and under mysql5, generate wrong code.
Class should allow me to dump my database into file.
easy restore that file.
generated file (.sql) should be compatible with phpmyadmin.
You will get better results using mysqldump as compared to phpMyAdmin's SQL Export especially when dealing with large databases and large strings of data
as #Dan mentioned, use exec() or shell_exec() to run the mysqldump command
MySQL has its own dump and import abilities. You can simply call use the mysqldump and mysql clients already installed on your server. If you want to wrap that functionality in a PHP script, build the commands as strings and use exec() or shell_exec() to run them on the system.

How do I register an mysql database?

Sorry for a noob question regarding MySQL. I downloaded FlightStats to learn about mysql but I can't figure out how to register it with my localhost mysql db. I know in MS SQL you can simply register any sql db using sql studio. I tried to google but come up with no result. Perhaps, my search phrase is wrong. I'm searching with "how to register a mysql database, register a mysql database...etc.". How do you register or setup an database from existing database like FlightStats? I'm using DBVisualizer. Is there a way in dbVis that I'm not aware of to regsiter a database?
Thanks
edit: sorry for the bad wording. I found this. I have the .myd, .myi and .frm and I want to get it to restore(?) with my local mysql instance. I look at all the answers but I'm still confuse as how you restore the database from those 3 files.
A little background first. The FlightStats download page linked to in the original question appears to provide zipped tarballs of the binary table storage files from the MySQL data directory. Given that this is considered a viable means of distribution, and combined with the use of MERGE tables, I would surmise that this tarball contains a bunch of MyISAM data files (.myi, .myd). Jack's edit confirms that this is the situation.
This is an atypical means of distributing a MySQL data set, although not at all uncommon when backing up MyISAM storage, and probably not all that unheard of for moving large data sets around; it likely works out considerably more space-efficient than a corresponding dump file. Of course, in SQL Server land, it's pretty common to attach database files into an instance.
Broadly speaking, you'd recover the database as follows:
Locate the MySQL data directory; typically /var/mysql or similar
Create a new directory with the desired database name e.g. flightdata
Extract the .myi, .myd and other files from the tarball into this directory
Make sure the entire directory is owned by the user MySQL runs as (usually mysql) - use chmod -R to make sure you get everything
Open a MySQL console
USE <database-name>
SHOW TABLES
You should see some tables listed. In addition, the downloads page linked includes a couple of SQL scripts, which contain SQL commands that you need to run against your database once it's in place. These will cause the merge definitions and table indexes to be rebuilt. You can pipe these into the command-line client, e.g. mysql -u<username> -p<password> <database-name> < <sql-file>.
It may be a good idea to shut down the MySQL server while you're doing this; use e.g. /etc/init.d/mysql stop or similar, and restart once the files are extracted in place.
There's generally a way to import sql files using a GUI database tool. I'm not familiar with DBVisualizer, but as long as you have a MySQL command line client installed you can do it there as well. It's pretty easy:
Create a blank schema. You can do this in your GUI tool or on the command line client. Just use CREATE DATABASE flightstats;, or whatever name you want.
Use the following command line syntax to import/run an sql file on the new schema: mysql -u <username> -p flightstats < /path/to/file.sql
The -p option prompts for a password. I generally set up the database using step 1 as the root user, then GRANT some permissions on it to a new user id, then use that user id to run the SQL file.
This process is pretty much what a GUI tool will do in the background.
Registering a database? dont know what that means however mysql gui tools can help you creating a database. Have a look at it or better you download phpmyadmin.
Google WAMP for Windows.
Google MAMP for Mac.
Google LAMP for Linux.
Any questions?