Translate
Friday, April 19, 2013
Friday, March 22, 2013
MySQL/Linux: Creating and restoring database backups using command line
Most of us have worked on different database technologies. MySQL is one amongst them.This tutorial explains the backup/restore process of db's in mysql.
Mysql provides a tool mysqldump which allows the user to take the backup of current state of the databases and restore them at a later point in time,if required.This tool comes in with the default installation of mysql server and can be used on the command line.
In this tutorial i am using mysql-server-5+ and Linux OS command line to explain the usage of this tool.
For a single database
Suppose you need to backup a single database.This command will do your work.
mysqldump -u root -p[root_password] [database_name] >filename.sql
So to backup a database named 'testing',the command would be
mysqldump -u root -p[root_password] testing > testing.sql
Note:The dump file testing.sqlwill be generated and stored in the directory location where you issue this command.However,you can specify your own directory location.Something like this
mysqldump -u root -p[root_password] [database_name] > /path/to/file
Now comes the restore part.To restore a dump into a database,the syntax is
mysql -u root -p[root_password] [database_name] < filename.sql
where filename.sql is the dump file generated using mysqldump command.
Suppose you need to restore the dump file generated in the previous step to a database named 'testing1'.The command is
mysql -u root -p[root_password] testing1 < testing.sql
Note: The database into which the dump needs to be restored(in this case testing1) should be created in advance (using the Create database) before dumping the content of the dump into file.Not doing so will throw up an error when the restoration is done.
For multiple databases
Sometimes it is necessary to back up more that one database at once. In this case you can use the --databases option followed by the list of databases you would like to backup. Each database name has to be separated by space.
mysqldump -u root -p[root_password] --databases db1 db2 > content_backup.sql
The above command will dump two databases db1 and db2 into the content_backup.sql file.
If you want to back up all the databases in the server at one time you should use the --all-databases option. It tells MySQL to dump all the databases it has in storage.
mysqldump -u root -p[root_password] --all-databases > alldb_backup.sql
Selective backup with mysqldump
The mysqldump utility also allows you to take selective backups in a database.You may want to backup one or more tables in database or,backup only selective data or records(using 'where' conditional clause).
With mysqldump command you can specify certain tables of your database you want to backup. For example, to back up only blog_template1 and blog_template2 tables from the ‘Templates’ database,use the command below. Each table name has to be separated by space.
mysqldump -u root -p[root_password] \blog_template1 blog_template2 > dbtemplate_backup.sql
For backing up or dumping only selective records in tables we can use the --where or -w option.For example,to backup the records from table t1 in the database db1 where vendor is google, the command will be
mysqldump -u root -p[root_password] db1 \t1 --where "vendor='google'" > t1.sql
This completes the tutorial on backing up/restoring data in mysql.Comments and feedbacks will be appreciated.Cheers!!!
Wednesday, March 6, 2013
Tweak your Ubuntu with this smart tool
There are several tools available for Windows for tweaking the look and feel of your WinOS. TweakUI,TweakNow,XDN Tweaker,Little Tweaker to name a few.However,most of you reading this post may not be aware of such tools for Ubuntu.Well there are a few and Ubuntu Tweak is one amongst them.
As quoted on Ubuntu Tweak website "Ubuntu Tweak is an application to config Ubuntu easier for everyone.It provides many useful desktop and system options that the default desktop environment doesn't provide."
So its time to explore this tool.
The HOME screen
The Home screen looks something like this.It provides basic info like hardware details,OS details,disk cache and system update.The 'Start Janitor' option can be used for cleaning up the disk cache and other junk which your system holds.We will review it further.You can also see different tabs at the top.These provide different functionalities.
The apps section
As the name suggests this section allows you to download apps for your Ubuntu OS.It features some handpicked tools as well as utilities for your entertainment.Try it out and i am sure you won't be disappointed.
Its time to do some tweaking
The 'Tweaks' section provides various categories of tweaks for your system.You can customize the look and interface of your OS.Click on the 'Love Wallpaper HD' icon and i am sure you would feel lucky.There's a lot more to explore in this section.Try it yourself.
For Admins only
This section is for the system administrators or users who have administrative privileges.This section can be used to manage files and applications.It also allows the superuser to edit and add new Sources other than the default one.The screenshots below will give you an idea about the various features.
Application Center
The application center provides a simple interface for finding and installing popular apps for your Ubuntu.One can argue it is a copycat of the apps section featured in this tweaking software,but hey,nothing is perfect in this world :)
File Type Manager
The name says it all.Just make sure that you make proper associations.
Source Center
The Janitor
The Janitor here is equivalent to the CCleaner app in Windows.Clean all the system's junk using this option.Allows you to clean out browser cache,apt-cache,temporary files,older kernel versions,unnecessary and broken packages.This is one feature that is highly recommended for all Ubuntu users.Get rid of the junk on just a click.Simple,isn't it.
Hope you enjoyed reading this review about Ubuntu Tweaks.Download the app from here and keep exploring.
As quoted on Ubuntu Tweak website "Ubuntu Tweak is an application to config Ubuntu easier for everyone.It provides many useful desktop and system options that the default desktop environment doesn't provide."
So its time to explore this tool.
The HOME screen
The Home screen looks something like this.It provides basic info like hardware details,OS details,disk cache and system update.The 'Start Janitor' option can be used for cleaning up the disk cache and other junk which your system holds.We will review it further.You can also see different tabs at the top.These provide different functionalities.
The apps section
As the name suggests this section allows you to download apps for your Ubuntu OS.It features some handpicked tools as well as utilities for your entertainment.Try it out and i am sure you won't be disappointed.
Its time to do some tweaking
The 'Tweaks' section provides various categories of tweaks for your system.You can customize the look and interface of your OS.Click on the 'Love Wallpaper HD' icon and i am sure you would feel lucky.There's a lot more to explore in this section.Try it yourself.For Admins only
This section is for the system administrators or users who have administrative privileges.This section can be used to manage files and applications.It also allows the superuser to edit and add new Sources other than the default one.The screenshots below will give you an idea about the various features.Application Center
The application center provides a simple interface for finding and installing popular apps for your Ubuntu.One can argue it is a copycat of the apps section featured in this tweaking software,but hey,nothing is perfect in this world :)
File Type Manager
The name says it all.Just make sure that you make proper associations.Source Center
The JanitorThe Janitor here is equivalent to the CCleaner app in Windows.Clean all the system's junk using this option.Allows you to clean out browser cache,apt-cache,temporary files,older kernel versions,unnecessary and broken packages.This is one feature that is highly recommended for all Ubuntu users.Get rid of the junk on just a click.Simple,isn't it.
Hope you enjoyed reading this review about Ubuntu Tweaks.Download the app from here and keep exploring.
Subscribe to:
Posts (Atom)






