Different Used Cases of Mysql dump command.


Backup of single database only:

mysqldump -u dbuser -p --databases dbname1 > dump.sql  [no compression]
mysqldump -u dbuser -p --databases dbname1 | gzip > dump.sql.gz  [gzip]
mysqldump -u dbuser -p --databases dbname1 | bzip2 > dump.sql.bz2  [bzip2]

Backup of all databases:

mysqldump -u dbuser -p --all-databases > dump.sql [no compression]
mysqldump -u dbuser -p --all-databases | gzip > dump.sql.gz  [gzip]
mysqldump -u dbuser -p --all-databases | bzip2 > dump.sql.bz2  [bzip2]

Backup of multiple databases [not all]:

mysqldump -u dbuser -p --databases dbname1 dbname2 > dump.sql
mysqldump -u dbuser -p --databases dbname1 dbname2 | gzip > dump.sql.gz  [gzip]
mysqldump -u dbuser -p --databases dbname1 dbname2 | bzip2 > dump.sql.bz2  [bzip2]

Backup of all databases with Triggers:

mysqldump -u dbuser -p --triggers --all-databases > dump.sql
mysqldump -u dbuser -p --triggers --all-databases | gzip > dump.sql.gz  [gzip]
mysqldump -u dbuser -p --triggers --all-databases | bzip2 > dump.sql.bz2  [bzip2]

Backup of all databases with  Procedures and Functions:

mysqldump -u dbuser -p --routines --all-databases > dump.sql
mysqldump -u dbuser -p --routines --all-databases | gzip > dump.sql.gz  [gzip]
mysqldump -u dbuser -p --routines --all-databases | bzip2 > dump.sql.bz2  [bzip2]

We need to create appropriately named database on the target machine that needs to be restored from the remote backup. Restore all database from the dump file:

mysql -u dbuser -p < dump.sql  [no compression]
gunzip < dump.sql.gz | mysql -u dbuser -p  [gzip]
bunzip2 < dump.sql.bz2 | mysql -u dbuser -p   [bzip2]

Restore single database from the dump file:

mysql -u dbuser -p dbname1 < dump.sql  [no compression]
gunzip < dump.sql.gz | mysql -u dbuser -p dbname1 [gzip]
bunzip2 < dump.sql.bz2 | mysql -u dbuser -p dbname1  [bzip2]
Advertisements

Date difference in Drupal 7.


Hi

Folks,

Find difference among two dates one will be the current date and other can be a variable date.

Format date is a Drupal function for reference find that in Drupal docs.

Your variable date could be $node->created. Which will return you the Date / time difference between current and the node created date/time.

function date_difference($case_time) {
$created_date = date(‘d-m-y’);
$node_date = format_date($case_time, ‘custom’, ‘d-m-y’);
$create_date=date_create($created_date);
$node_create_date =date_create($node_date);
$date_diff = date_diff($date1,$date2);
return $date_diff;
}

How to Change a File Extension


Edited by Oliver, Chocola, Illneedasaviour, BR and 2 others

There will almost inevitably come a time when you need a document from one program to become accessible by another program. File extensions show which program will open the file. Knowing how to change a file extension is something well learned. Most of this type of change occurs between a word processing program and desktop publishing or HTML code. The steps below are what you would use to change a file extension in Windows.

Steps

  1. 1

    Know which document you want to be able to change the file extension of.

    • Make a copy of this file and save it as another name so you will still be able to open the original in your word processing program.
      Change a File Extension Step 1Bullet1.jpg
    • Close the word processing program. You will work with the copied file from here on.
      Change a File Extension Step 1Bullet2.jpg
    Ad
  2. Find or Change My Computer's Administrator Step 1 Version 2.jpg
    2

    Select the “Start” button on the bottom left of your screen. Click your mouse to bring up the control panel. See the right side of the new screen.

    • Select “Appearance and Personalization.”
      Change a File Extension Step 2Bullet1.jpg
    • Now, select “Folder Options,” and then the “View” tab.
      Change a File Extension Step 2Bullet2.jpg
    • Go down the list until you find “Hide extensions for known file types.” Uncheck that box.
      Change a File Extension Step 2Bullet3.jpg
    • Click on “Apply” and close the control options boxes.
      Change a File Extension Step 2Bullet4.jpg
  3. 3

    Reopen the directory where the file is located.

    • Place your cursor on the file copy you just made. Right-click the file, making sure not to use a shortcut file.
      Change a File Extension Step 3Bullet1.jpg
    • Select “Rename” from the options they give you.
      Change a File Extension Step 3Bullet2.jpg
    • Change the extension manually by retyping the new program extension you want to use. Type .html if changing to HTML code and make it .txt if you want it to be a text file.
      Change a File Extension Step 3Bullet3.jpg
    • Move this file to the appropriate directory if you need to.
  4. 4

    Understand the file has not undergone any new formatting as a result of this name change. It will open only if the desired program accepts it.

    • Otherwise, you may have to simply use copied text and graphics from the original document into a blank documents created in the new program. This workaround does not work on music files, but is great for newsletter articles in HTML code or a desktop publishing program.
    • You may have to change the word processing file into a text file (extension will be .txt) in some instances before saving it into the desktop publishing or .html file.
    • There are file conversion software programs available as well as online sites dedicated to just this purpose. Some are free to use, while others cost something. So, do your homework before trying them.
      Change a File Extension Step 4Bullet3.jpg

How to run Linux commands on Windows.


I have been a linux geek for a while in my life and love to use linux commands on the windows UI. I found an alternate to use both as i believe to use the best.

Here is the screancast :

Step by step guide how to install cygwin

Cygwin is a Unix-like environment and command-line interface for Microsoft Windows. Cygwin provides native integration of Windows-based applications, data, and other system resources with applications, software tools, and data of the Unix-like environment. Thus it is possible to launch Windows applications from the Cygwin environment, as well as to use Cygwin tools and applications within the Windows operating context.

Ok, I’ll show how to install Cygwin on Windows 7

Download latest version of Cygwin

Click here to download Cygwin

Scroll down and click Install or update now!

install_cygwin_win7_1.png

I use download manager to save time.

install_cygwin_win7_2.png

Save to my document of other drive.

Install Cygwin on Windows 7[/h]Double click installer to start install.

Choose “Install from internet

Click Next.

install_cygwin_win7_4.png

Select Root Install Directory

Let it as is and choose Install For “All Users

Click Next.

install_cygwin_win7_5.png

Select Local Package Directory

Let it as is. Click Next.

install_cygwin_win7_6.png

Select Your Internet Connection

Setup wizard provide 3 type of connections :

*Direct Connection
*Use IE5 Settings
*Use HTTP/FTP Proxy

I use Direct Connection since I have no Proxy connection.

Click Next.

install_cygwin_win7_7.png

Choose A download Site

Choose nearest location to your position.

Click Next when you’re done.

install_cygwin_win7_8.png

Cygwin setup will process and show the progress.

install_cygwin_win7_9.png

Setup Alert

New alert remind me about the release. Its major release that might affect existing cygwin installation. Since I don’t have existing installation of Cygwin I choose OK.

install_cygwin_win7_10.png

Select Packages

You can choose the packages you want to install.

Choose anything from the list and click Next when you’re done.

install_cygwin_win7_11.png

Resolving Dependencies

Click Next.

install_cygwin_win7_12.png

Create Icons

I choose to Add icon to Start menu.

click Finish.

install_cygwin_win7_13.png

Start Cygwin Bash Shell[/h]Click Start menu and Find Cygwin . Click on Cygwin Bash Shell to start the shell.

install_cygwin_win7_14.png

New Cygwin bash Shell will appear and you can start playing around with command.

install_cygwin_win7_15.png

I enter some command like:

uname -a
df -H
ls -l

Yes, all those command successfully executed.

Having fun with Cygwin.

"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime."

%d bloggers like this: