How to Backup and Restore MySQL Database on Fedora16, Centos and Redhat
The mysqldump client is a backup program originally written by Igor Romanenko. It can be used to dump a database or a collection of databases for backup or transfer to another SQL server (not necessarily a MySQL server). The dump typically contains SQL statements to create the table, populate it, or both. However, mysqldump can also be used to generate files in CSV, other delimited text, or XML format.
Source RPM : mysql-5.5.20-1.fc16.src.rpm Build Date : Fri 27 Jan 2012 09:17:21 AM CET Build Host : x86-04.phx2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : http://www.mysql.com Summary : The MySQL server and related files
1- Start mysql server
[pirat9@Fedora16 ~]$ sudo service mysqld start
Connect to the Server with
[pirat9@Fedora16 ~]$ mysql -u root -p Output Enter password: Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 2 Server version: 5.5.20 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
2- Create new database
In my case i created a new database called unixmen
mysql> create database unixmen;
Query OK, 1 row affected (0.00 sec)
-Show databases with
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | test1 | | unixmen | +--------------------+ 6 rows in set (0.00 sec)
3- Backup mysql database
Backup MySQL database to <databasebackupfiles>.sql
<databasename> = Target existing database name
<databasebackupfiles> = Preferred backed up file name
# mysqldump -u root -p <databasename> > <databasebackupfiles>.sql Enter password: <Type your mysql password and press enter
i will back up the database named <unixmen> to mylbackup file. This will taking backed up all the tables including the data :
# mysqldump -u root -p unixmen > backup.sql Enter password:
View the content on mysqlbackup.sql
4- Restore MySQL database
To restore the backed up database named “mbackup.sql” to new database named “new” as below :
# mysql -u root -p <mysqlpassword> <databasename> < <databasebackupfiles>.sql
<mysqlpassword> = MySQL password
<databasename> = Database name that will be restore
<databasebackupfiles> = Backed up database file, normally .sql file
Create the new database mysqlnew :
mysql> CREATE DATABASE mysqlnew; Query OK, 1 row affected (0.01 sec)
As example, i will restore the mysqlbackup.sql backed up file to database named “new” :
# mysql -u root -p password new < mysqlbackup.sql
mysql -u root -p new < mysqlbackup.sql
Like us on Facebook
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- How To Show Username On Panel In Ubuntu 13.04/13.10 : By default usernames are not displayed on panel in Ubuntu 13.04 and 13.10, In this simple tutorial w...0 comments |
- cowsay And fortune Combined Together : Hi linux geeks! In this article I will teach you a nice trick you can perform in the terminal with ...0 comments |
- How To Install Netflix In Ubuntu : Hi unixmen readers! How are you? In this article we will teach you how to install the desktop vers...1 comment |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comments |
- How To Install Netflix In Ubuntu
- cowsay And fortune Combined Together
- How To Show Username On Panel In Ubuntu 13.04/13.10
- Setup DNS Server On openSUSE 13.1
- TeamViewer 9 Final Has Been Released!
- Twelve Vulnerabilities Have Been Fixed In Ubuntu 12.04, Time To Update
- OpenLDAP Installation and Configuration in Ubuntu 12.10/13.04/13.10 And Debian 6/7
- Configure Your Browser To Use Tor On Ubuntu/Debian/Linux Mint
- Setup A Full Featured ITIL Management System Using Integria IMS On CentOS 6
- Install LibreOffice 4.1.3 in Elementary OS ‘Luna’
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .