逃离这么久,终于还记得这里有个home ,忙,忙 … 忙的忘记了时间。
回来,其实只为了这段代码 7032991e
呵呵
看的懂吗? !
一段做了又做的代码,为了测试这个blog归我所有
呵呵
代码 2 7032991e
行进中的破车
逃离这么久,终于还记得这里有个home ,忙,忙 … 忙的忘记了时间。
回来,其实只为了这段代码 7032991e
呵呵
看的懂吗? !
一段做了又做的代码,为了测试这个blog归我所有
呵呵
代码 2 7032991e
摘录:有用的表格(三)Treebeard’s Unix Cheat Sheet
http://www.rain.org/%7emkummel/unix.html
| Help on any Unix command. RTFM! | |||||||||||||||||||||||
| man {command} | Type man ls to read the manual for the ls command. | ||||||||||||||||||||||
| man {command} > {filename} | Redirect help to a file to download. | ||||||||||||||||||||||
| whatis {command} | Give short description of command. (Not on RAIN?) | ||||||||||||||||||||||
| apropos {keyword} | Search for all Unix commands that match keyword, eg apropos file. (Not on RAIN?) | ||||||||||||||||||||||
| List a directory | |||||||||||||||||||||||
| ls {path} | It’s ok to combine attributes, eg ls -laF gets a long listing of all files with types. | ||||||||||||||||||||||
| ls {path_1} {path_2} | List both {path_1} and {path_2}. | ||||||||||||||||||||||
| ls -l {path} | Long listing, with date, size and permisions. | ||||||||||||||||||||||
| ls -a {path} | Show all files, including important .dot files that don’t otherwise show. | ||||||||||||||||||||||
| ls -F {path} | Show type of each file. “/” = directory, “*” = executable. | ||||||||||||||||||||||
| ls -R {path} | Recursive listing, with all subdirs. | ||||||||||||||||||||||
| ls {path} > {filename} | Redirect directory to a file. | ||||||||||||||||||||||
| ls {path} | more | Show listing one screen at a time. | ||||||||||||||||||||||
| dir {path} | Useful alias for DOS people, or use with ncftp. | ||||||||||||||||||||||
| Change to directory | |||||||||||||||||||||||
| cd {dirname} | There must be a space between. | ||||||||||||||||||||||
| cd ~ | Go back to home directory, useful if you’re lost. | ||||||||||||||||||||||
| cd .. | Go back one directory. | ||||||||||||||||||||||
| cdup | Useful alias, like “cd ..”, or use with ncftp. | ||||||||||||||||||||||
| Make a new directory | |||||||||||||||||||||||
| mkdir {dirname} | |||||||||||||||||||||||
| Remove a directory | |||||||||||||||||||||||
| rmdir {dirname} | Only works if {dirname} is empty. | ||||||||||||||||||||||
| rm -r {dirname} | Remove all files and subdirs. Careful! | ||||||||||||||||||||||
| Print working directory | |||||||||||||||||||||||
| pwd | Show where you are as full path. Useful if you’re lost or exploring. | ||||||||||||||||||||||
| Copy a file or directory | |||||||||||||||||||||||
| cp {file1} {file2} | |||||||||||||||||||||||
| cp -r {dir1} {dir2} | Recursive, copy directory and all subdirs. | ||||||||||||||||||||||
| cat {newfile} >> {oldfile} | Append newfile to end of oldfile. | ||||||||||||||||||||||
| Move (or rename) a file | |||||||||||||||||||||||
| mv {oldfile} {newfile} | Moving a file and renaming it are the same thing. | ||||||||||||||||||||||
| mv {oldname} {newname} | |||||||||||||||||||||||
| Delete a file | |||||||||||||||||||||||
| rm {filespec} | ? and * wildcards work like DOS should. “?” is any character; “*” is any string of characters. | ||||||||||||||||||||||
| ls {filespec} rm {filespec} |
Good strategy: first list a group to make sure it’s what’s you think… …then delete it all at once. |
||||||||||||||||||||||
| Download with zmodem | (Use sx with xmodem.) | ||||||||||||||||||||||
| sz [-a|b] {filename} | -a = ascii, -b = binary. Use binary for everything. (It’s the default?) | ||||||||||||||||||||||
| sz *.zip | Handy after downloading with FTP. Go talk to your spouse while it does it’s stuff. | ||||||||||||||||||||||
| Upload with zmodem | (Use rx with xmodem.) | ||||||||||||||||||||||
| rz [-a|b] (filename} | Give rz command in Unix, THEN start upload at home. Works fine with multiple files. | ||||||||||||||||||||||
| View a text file | |||||||||||||||||||||||
| more {filename} | View file one screen at a time. | ||||||||||||||||||||||
| less {filename} | Like more, with extra features. | ||||||||||||||||||||||
| cat {filename} | View file, but it scrolls. | ||||||||||||||||||||||
| cat {filename} | more | View file one screen at a time. | ||||||||||||||||||||||
| page {filename} | Very handy with ncftp. | ||||||||||||||||||||||
| pico {filename} | Use text editor and don’t save. | ||||||||||||||||||||||
| Edit a text file. | |||||||||||||||||||||||
| pico {filename} | The same editor PINE uses, so you already know it. vi and emacs are also available. | ||||||||||||||||||||||
| Create a text file. | |||||||||||||||||||||||
| cat > {filename} | Enter your text (multiple lines with enter are ok) and press control-d to save. | ||||||||||||||||||||||
| pico {filename} | Create some text and save it. | ||||||||||||||||||||||
| Compare two files | |||||||||||||||||||||||
| diff {file1} {file2} | Show the differences. | ||||||||||||||||||||||
| sdiff {file1} {file2} | Show files side by side. | ||||||||||||||||||||||
| Other text commands | |||||||||||||||||||||||
| grep ‘{pattern}’ {file} | Find regular expression in file. | ||||||||||||||||||||||
| sort {file1} > {file2} | Sort file1 and save as file2. | ||||||||||||||||||||||
| sort -o {file} {file} | Replace file with sorted version. | ||||||||||||||||||||||
| spell {file} | Display misspelled words. | ||||||||||||||||||||||
| wc {file} | Count words in file. | ||||||||||||||||||||||
| Find files on system | |||||||||||||||||||||||
| find {filespec} | Works with wildcards. Handy for snooping. | ||||||||||||||||||||||
| find {filespec} > {filename} | Redirect find list to file. Can be big! | ||||||||||||||||||||||
| Make an Alias | |||||||||||||||||||||||
| alias {name} ‘{command}’ | Put the command in ’single quotes’. More useful in your .cshrc file. | ||||||||||||||||||||||
| Wildcards and Shortcuts | |||||||||||||||||||||||
| * | Match any string of characters, eg page* gets page1, page10, and page.txt. | ||||||||||||||||||||||
| ? | Match any single character, eg page? gets page1 and page2, but not page10. | ||||||||||||||||||||||
| […] | Match any characters in a range, eg page[1-3] gets page1, page2, and page3. | ||||||||||||||||||||||
| ~ | Short for your home directory, eg cd ~ will take you home, and rm -r ~ will destroy it. | ||||||||||||||||||||||
| . | The current directory. | ||||||||||||||||||||||
| .. | One directory up the tree, eg ls ... | ||||||||||||||||||||||
| Pipes and Redirection | (You pipe a command to another command, and redirect it to a file.) | ||||||||||||||||||||||
| {command} > {file} | Redirect output to a file, eg ls > list.txt writes directory to file. | ||||||||||||||||||||||
| {command} >> {file} | Append output to an existing file, eg cat update >> archive adds update to end of archive. | ||||||||||||||||||||||
| {command} | Get input from a file, eg sort | ||||||||||||||||||||||
| {command} {file2} | Get input from file1, and write to file2, eg sort new.txt sorts old.txt and saves as new.txt. | ||||||||||||||||||||||
| {command} | {command} | Pipe one command to another, eg ls | more gets directory and sends it to more to show it one page at a time. | ||||||||||||||||||||||
| Permissions, important and tricky! | |||||||||||||||||||||||
Unix permissions concern who can read a file or directory, write to it, and execute it. Permissions are granted or withheld with a magic 3-digit number. The three digits correspond to the owner (you); the group (?); and the world (everyone else).Think of each digit as a sum:
|
|||||||||||||||||||||||
| Add the number value of the permissions you want to grant each group to make a three digit number, one digit each for the owner, the group, and the world. Here are some useful combinations. Try to figure them out! | |||||||||||||||||||||||
| chmod 600 {filespec} | You can read and write; the world can’t. Good for files. | ||||||||||||||||||||||
| chmod 700 {filespec} | You can read, write, and execute; the world can’t. Good for scripts. | ||||||||||||||||||||||
| chmod 644 {filespec} | You can read and write; the world can only read. Good for web pages. | ||||||||||||||||||||||
| chmod 755 {filespec} | You can read, write, and execute; the world can read and execute. Good for programs you want to share, and your public_html directory. | ||||||||||||||||||||||
| Permissions, another way | |||||||||||||||||||||||
You can also change file permissions with letters:
|
|||||||||||||||||||||||
| chmod u+rw {filespec} | Give yourself read and write permission | ||||||||||||||||||||||
| chmod u+x {filespec} | Give yourself execute permission. | ||||||||||||||||||||||
| chmod a+rw {filespec} | Give read and write permission to everyone. | ||||||||||||||||||||||
| Applications I use | |||||||||||||||||||||||
| finger {userid} | Find out what someone’s up to. | ||||||||||||||||||||||
| gopher | Gopher. | ||||||||||||||||||||||
| irc | IRC, but not available on RAIN. | ||||||||||||||||||||||
| lynx | Text-based Web browser, fast and lean. | ||||||||||||||||||||||
| ncftp | Better FTP. | ||||||||||||||||||||||
| pico {filename} | Easy text editor, but limited. vi and emacs are available. | ||||||||||||||||||||||
| pine | Email. | ||||||||||||||||||||||
| telnet {host} | Start Telnet session to another host. | ||||||||||||||||||||||
| tin | Usenet. | ||||||||||||||||||||||
| uudecode {filename} uuencode {filename} |
Do it on the server to reduce download size about 1/3. | ||||||||||||||||||||||
| ytalk {userid} | Chat with someone else online, eg ytalk mkummel. Please use w first so you don’t interrupt a big download! | ||||||||||||||||||||||
| System info | |||||||||||||||||||||||
| date | Show date and time. | ||||||||||||||||||||||
| df | Check system disk capacity. | ||||||||||||||||||||||
| du | Check your disk usage and show bytes in each directory. | ||||||||||||||||||||||
| more /etc/motd | Read message of the day, “motd” is a useful alias.. | ||||||||||||||||||||||
| printenv | Show all environmental variables (in C-shell% - use set in Korn shell$). | ||||||||||||||||||||||
| quota -v | Check your total disk use. | ||||||||||||||||||||||
| uptime | Find out system load. | ||||||||||||||||||||||
| w | Who’s online and what are they doing? | ||||||||||||||||||||||
Long listings (ls -l) have this format:
- file d directory, * executable ^ symbolic links (?) file size (bytes) file name / directory ^ ^ ^ ^ ^ drwxr-xr-x 11 mkummel 2560 Mar 7 23:25 public_html/ -rw-r–r– 1 mkummel 10297 Mar 8 23:42 index.html ^ ^^^ user permission (rwx) date and time last modified ^^^ group permission (rwx) ^^^ world permission (rwx)
An alias lets you type something simple and do something complex. It’s a shorthand for a command. If you want to type “dir” instead of “ls -l” then type alias dir ‘ls -l’. The single quotes tell Unix that the enclosed text is one command.Aliases are more useful if they’re permanent so you don’t have to think about them. You can do this by adding the alias to your .cshrc file so they’re automatically loaded when you start. Type pico .cshrc and look for the alias section and add what you want. It will be effective when you start. Just remember that if you make an alias with the name of a Unix command, that command will become unavailable.
Here are a few aliases from my .cshrc file:
# enter your aliases here in the form: # alias this means this alias h history alias m more alias q quota -v alias bye exit alias ls ls -F alias dir ls alias cdup cd .. alias motd more /etc/motd
A Unix script is a text file of commands that can be executed, like a .bat file in DOS. Unix contains a powerful programming language with loops and variables that I don’t really understand. Here’s a useful example.Unix can’t rename a bunch of files at once the way DOS can. This is a problem if you develop Web pages on a DOS machine and then upload them to your Unix Server. You might have a bunch of .htm files that you want to rename as .html files, but Unix makes you do it one by one. This is actually not a defect. (It’s a feature!) Unix is just being more consistent than DOS. So make a script!
Make a text file (eg with pico) with the following lines. The first line is special. It tells Unix what program or shell should execute the script. Other # lines are comments.
#! /bin/csh # htm2html converts *.htm files to *.html foreach f ( *.htm ) set base=`basename $f .htm` mv $f $base.html endSave this in your home directory as htm2html (or whatever). Then make it user-executable by typing chmod 700 htm2html. After this a * will appear by the file name when you ls -F, to show that it’s executable. Change to a directory with .htm files and type ~/htm2html, and it will do its stuff.Think about scripts whenever you find yourself doing the same tedious thing over and over.
Dotfile names begin with a “.” These files and directories don’t show up when you list a directory unless you use the -a option, so they are also called hidden files. Type ls -la in your home directory to see what you have.Some of these dotfiles are crucial. They initialize your shell and the programs you use, like autoexec.bat in DOS and .ini files in Windows. rc means “run commands”. These are all text files that can be edited, but change them at your peril. Make backups first!
Here’s some of what I get when I type ls -laF:
.addressbook my email addressbook. .cshrc my C-shell startup info, important! .gopherrc my gopher setup. .history list of past commands. .login login init, important! .lynxrc my lynx setup for WWW. .ncftp/ hidden dir of ncftp stuff. .newsrc my list of subscribed newsgroups. .pinerc my pine setup for email. .plan text appears when I’m fingered, ok to edit. .profile Korn shell startup info, important! .project text appears when I’m fingered, ok to edit. .signature my signature file for mail and news, ok to edit. .tin/ hidden dir of my tin stuff for usenet. .ytalkrc my ytalk setup.
Action DOS UNIX change directory cd cd change file protection attrib chmod compare files comp diff copy file copy cp delete file del rm delete directory rd rmdir directory list dir ls edit a file edit pico environment set printenv find string in file find grep help help man make directory md mkdir move file move mv rename file ren mv show date and time date, time date show disk space chkdsk df show file type cat show file by screens type filename | more more sort data sort sort
http://www.googleguide.com/advanced_operators_reference.html
| (A printable PDF version is available.) | ||||
| Basic Examples | ||||
| This Search | Finds Pages Containing… | |||
| biking Italy | the words biking and Italy | |||
| recycle steel OR iron | information on recycling steel or recycling iron | |||
| “I have a dream“ | the exact phrase I have a dream | |||
| salsa –dance | the word salsa but NOT the word dance | |||
| Louis +I France | information about Louis the First (I), weeding out other kings of France | |||
| castle ~glossary | glossaries about castles, as well as dictonaries, lists of terms, terminology, etc. | |||
| fortune-telling | all forms of the term, whether spelled as a single word, a phrase, or hyphenated | |||
| define:imbroglio | definitions of the word imbroglio from the Web | |||
| “Nancy * Blachman“ | the words Nancy and Blachman separated by exactly one word | |||
| Calculator | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| + – * / | basic arithmetic | 12 + 34 - 56 * 7 / 8 | ||
| % of | percentage of | 45% of 39 | ||
| ^ or ** | raise to a power | 2^5 or 2**5 | ||
| the nth root of | nth root | 4th root of 16 | ||
| old units in new units | convert units | 300 Euros in USD, 130 lbs in kg, or 31 in hex | ||
| Restrict Search | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| city1 city2 | Book flights. | sfo bos (Book flights from San Francisco (SFO) to Boston (BOS).) |
||
| site: | Search only one website or domain. | Halloween site:www.census.gov (Search for information on Halloween gathered by the US Census Bureau.) |
||
| [#]..[#] | Search within a range of numbers. | Dave Barry pirate 2002..2006 (Search for Dave Barry articles mentioning pirates written in these years.) |
||
| filetype: (or ext:) |
Find documents of the specified type. | Form 1098-T IRS filetype:pdf (Find the US tax form 1098-T in PDF format.) |
||
| link: | Find linked pages, i.e., show pages that point to the URL. | link:warriorlibrarian.com (Find pages that link to Warrior Librarian’s website.) |
||
| Specialized Information Queries | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| book (or books) |
Search full-text of books. | book Ender’s Game (Show book-related information. Note: No colon needed after book.) |
||
| define, what is, what are | Show a definition for a word or phrase. | define monopsony, what is podcast (Show a definition for the words monopsony and podcast. Note: No colon after define, what is, or what are.) |
||
| define: | Provide definitions for words, phrases, and acronyms from the Web. | define:kerning (Find definitions for kerning from the Web.) |
||
| phonebook: | Show all phonebook listings. | phonebook: Disney CA (Search for Disney’s phone numbers in California - CA.) |
||
| rphonebook: | Show residential phonebook listings. | rphonebook: bill jones NY (Search for the phone number of every Bill Jones in New York State - NY.) |
||
| movie: | Find reviews and showtimes. | movie: traffic (Search for information about this movie, including reviews, showtimes, etc.) |
||
| stocks: | Given ticker symbols, show stock information | stocks: goog (Find Google’s current stock price.) |
||
| weather | Given a location (US zip code or city), show the weather | weather Seattle WA, weather 81612 (Show the current weather and forecast. Note: No colon after weather.) |
||
| Alternative Query Types | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| cache: | Display Google’s cached version of a web page. | cache:www.irs.gov (Show Google’s cached version of the US Internal Revenue Service home page.) |
||
| info: (or id:) |
Find info about a page. | info:www.theonion.com (Find information about The Onion website.) |
||
| related: | List web pages that are similar or related to the URL. | related:www.healthfinder.gov (Find websites related to the Healthfinder website.) |
||
| Restrict Search to Sites where Query Words Appear | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| allinanchor: | All query words must appear in anchor text of links to the page. | allinanchor:useful parenting sites (Search for pages that are called useful parenting sites by others.) |
||
| inanchor: | Terms must appear in anchor text of links to the page. | restaurants Portland inanchor:kid-friendly (Search for pages on Portland restaurants for which links to the page say they are “kid friendly.”) |
||
| allintext: | All query words must appear the in text of the page. | allintext:ingredients cilantro chicken lime (Search for recipes with these three ingredients.) |
||
| intext: | The terms must appear in the text of the page. |
Dan Shugar intext:Powerlight (Find pages mentioning Dan Shugar where his company, Powerlight, is included in the text of the page, i.e., less likely to be from the corporate website.) |
||
| allintitle: | All query words must appear in the title of the page. | allintitle: Google Advanced Operators (Search for pages with titles containing “Google,” “Advanced,”, and “Operators”.) |
||
| intitle: | The terms must appear in the title of the page. | movies comedy intitle:top ten (Search for pages with the words movie and comedy that include top ten in the title of the page.) |
||
| allinurl: | All query words must appear in the URL. | allinurl:pez faq (Search for pages containing the words pez & faq in the URL.) |
||
| inurl: | The terms must appear in the URL of the page. | pharmaceutical inurl:investor (Search for pages in which the URL contains the word investor.) |
||
| Restrict Search to Google Groups | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| author: | Find Groups messages from the specified author. | flying author:Hamish author:Reid (Search for Hamish Reid’s articles on flying.) |
||
| group: | Find Groups messages from the specified newsgroup. | ivan doig group:rec.arts.books (Search for postings about Ivan Doig in the group rec.arts.books.) |
||
| insubject: | Find Groups messages containing crazy quilts in the subject. | insubject:”crazy quilts” (Find articles containing crazy quilts in the subject line.) |
||
| Restrict Search to Google News | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| location: | Find News articles from sources located in the specified location. | queen location:uk (Find British news articles on the Queen.) |
||
| source: | Find News articles from specified sources. | peace source:ha_aretz (Show articles on peace from the Israeli newspaper Ha’aretz.) |
||
| Restrict Search to Froogle | ||||
| Operators | Meaning | Type Into Search Box (& Results) | ||
| store: | Find Froogle products from the specified store. | jeans store:gap (Find Gap jeans.) |
||
| About This Cheat Sheet | ||||||
![]() |
For more tips, tricks, & examples, visit www.GoogleGuide.com. By Nancy Blachman, Tasha Bergson-Michelson, & Jerry Peek who don’t work for Google. Thank you Matt Vance for the idea of creating a Google Guide cheat sheet. |
|||||
| Please email suggestions or corrections to nancy(at)googleguide.com (replace (at) by @). |
||||||
| This page was last modified on Saturday December 23, 2006 | ||||||
MYSQL Cheat Sheets
http://www.nparikh.org/unix/mysql.php
Selecting a database:
mysql> USE database;
Listing databases:
mysql> SHOW DATABASES;
Listing tables in a db:
mysql> SHOW TABLES;
Describing the format of a table:
mysql> DESCRIBE table;
Creating a database:
mysql> CREATE DATABASE db_name;
Creating a table:
mysql> CREATE TABLE table_name (field1_name TYPE(SIZE), field2_name TYPE(SIZE));
Ex: mysql> CREATE TABLE pet (name VARCHAR(20), sex CHAR(1), birth DATE);
Load tab-delimited data into a table:
mysql> LOAD DATA LOCAL INFILE “infile.txt” INTO TABLE table_name; (Use n for NULL)
Inserting one row at a time:
mysql> INSERT INTO table_name VALUES (’MyName’, ‘MyOwner’, ‘2002-08-31′); (Use NULL for NULL)
Retrieving information (general):
mysql> SELECT from_columns FROM table WHERE conditions;
All values: SELECT * FROM table;
Some values: SELECT * FROM table WHERE rec_name = “value”;
Multiple critera: SELECT * FROM TABLE WHERE rec1 = “value1″ AND rec2 = “value2″;
Reloading a new data set into existing table:
mysql> SET AUTOCOMMIT=1;
# used for quick recreation of table
mysql> DELETE FROM pet;
mysql> LOAD DATA LOCAL INFILE “infile.txt” INTO TABLE table;
Fixing all records with a certain value:
mysql> UPDATE table SET column_name = “new_value” WHERE record_name = “value”;
Selecting specific columns:
mysql> SELECT column_name FROM table;
Retrieving unique output records:
mysql> SELECT DISTINCT column_name FROM table;
Sorting:
mysql> SELECT col1, col2 FROM table ORDER BY col2;
Backwards: SELECT col1, col2 FROM table ORDER BY col2 DESC;
Date calculations:
mysql> SELECT CURRENT_DATE, (YEAR(CURRENT_DATE)-YEAR(date_col)) AS time_diff [FROM table];
MONTH(some_date) extracts the month value and DAYOFMONTH() extracts day.
Pattern Matching:
mysql> SELECT * FROM table WHERE rec LIKE “blah%”;
(% is wildcard - arbitrary # of chars)
Find 5-char values: SELECT * FROM table WHERE rec like “_____”; (_ is any single character)
Extended Regular Expression Matching:
mysql> SELECT * FROM table WHERE rec RLIKE “^b$”;
(. for char, […] for char class, * for 0 or more instances ^ for beginning,
{n} for repeat n times, and $ for end)
(RLIKE or REGEXP) To force case-sensitivity, use “REGEXP BINARY”
Counting Rows:
mysql> SELECT COUNT(*) FROM table;
Grouping with Counting:
mysql> SELECT owner, COUNT(*) FROM table GROUP BY owner;
(GROUP BY groups together all records for each ‘owner’)
Selecting from multiple tables:
(Example) mysql> SELECT pet.name, comment FROM pet, event WHERE pet.name = event.name;
(You can join a table to itself to compare by using ‘AS’)
Currently selected database:
mysql> SELECT DATABASE();
Maximum value:
mysql> SELECT MAX(col_name) AS label FROM table;
Auto-incrementing rows:
mysql> CREATE TABLE table (number INT NOT NULL AUTO_INCREMENT, name CHAR(10) NOT NULL);
mysql> INSERT INTO table (name) VALUES (”tom”),(”dick”),(”harry”);
Adding a column to an already-created table:
mysql> ALTER TABLE tbl ADD COLUMN [column_create syntax] AFTER col_name;
Removing a column:
mysql> ALTER TABLE tbl DROP COLUMN col;
(Full ALTER TABLE syntax available at mysql.com.)
Batch mode (feeding in a script):
# mysql -u user -p source batch_file;
Backing up a database with mysqldump:
# mysqldump –opt -u username -p database > database_backup.sql
(Use ‘mysqldump –opt –all-databases > all_backup.sql’ to backup everything.)
(More info at MySQL’s docs.)