mysqldump -uroot -p123456 --default-character-set=gbk --opt $i | gzip > /backup/$dateDIR/data/${i}_${dateDIR}.sql.gz
请问
--opt 这里是什么意思  ?

解决方案 »

  1.   

     --opt该选项是速记;等同于指定 --add-drop-tables--add-locking --create-option --disable-keys--extended-insert --lock-tables --quick --set-charset。它可以给出很快的转储操作并产生一个可以很快装入MySQL服务器的转储文件。该选项默认开启,但可以用--skip-opt禁用。要想只禁用确信用-opt启用的选项,使用--skip形式;例如,--skip-add-drop-tables或--skip-quick。
      

  2.   

    还不是很明白能结合
    mysqldump -uroot -p123456 --default-character-set=gbk --opt $i | gzip > /backup/$dateDIR/data/${i}_${dateDIR}.sql.gz
    解释有没有这opt的区别?
      

  3.   

    帮助文档中去看  --add-drop-tables--add-locking --create-option --disable-keys--extended-insert --lock-tables --quick --set-charset 这些选项的含义。
      

  4.   

    man mysqldump
    看明白楼上 translate 不准备 最好直接用英文
    shorthand   缩写 
      

  5.   

    -lock-tables--------------文档说要lock all tables所以他不适合在线数据库的db ??
      

  6.   

    [原创]有关MYSQLDUMP的详细解释( 2007-11-25日更新)早上朋友问这个问题,我就把这些选项详细整理一下,偶会随时更新的。
    前提: 使用mysqldump的用户,必须至少具有SELECT 和 LOCK TABLES的权限。库或者表。如果要使用--tab开关,还必须有FILE的权限准备工作:库以及表:Table   Create Table                            
    ------  -----------------------------------------
    pwss    CREATE TABLE `pwss` (                   
              `id` int(11) NOT NULL AUTO_INCREMENT, 
              `username` varchar(64) DEFAULT NULL,  
              `description` mediumtext,             
              PRIMARY KEY (`id`)                    
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8    mysql> grant usage on *.* to 'dump_user'@'localhost' identified by 'dump_user';
    Query OK, 0 rows affected (0.00 sec)(这个语句可以省略,因为默认的都有USAGE权限。)mysql> grant lock tables on *.* to 'dump_user'@'localhost';
    Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)mysql> show grants for 'dump_user'@'localhost';
    +-------------------------------------------------------------------------------
    -----------------------------------------+
    | Grants for dump_user@localhost
                                             |
    +-------------------------------------------------------------------------------
    -----------------------------------------+
    | GRANT LOCK TABLES ON *.* TO 'dump_user'@'localhost' IDENTIFIED BY PASSWORD '*9
    E3A8684DFAF643FD3D08D24C0432C0101417D8B' |
    +-------------------------------------------------------------------------------
    -----------------------------------------+
    1 row in set (0.00 sec)如果您想把整个数据库woshitTest的内容导到一个文件中,可以使用下面的命令:C:\>mysqldump -udump_user -pdump_user woshitTest > c:\\woshitTestDumpFile.txt(默认的是当前路径,其他的请用完整路径)
      这条命令行也可以加上以下开关: --databases (--all-databases)如果只是想单独把表 pwSS 导出:
    C:\>mysqldump -udump_user -pdump_user woshitTest pwss> c:\\woshitTestDumpFilePwss.txt如果你想要导出某一条记录的话,带上开关--where="你的SQL语句"--where="id=1" 或者 -w="id=1"MYSQLDUMP 还有其他的开关列表如下:  --add-drop-table这个选项将会在每一个表的前面加上DROP TABLE IF EXISTS语句,这样可以保证IMPORT您的MySQL数据库的时候不会出错,因为每次导回的时候,都会首先检查表是否存在,存在就删除  --add-locks(这个开关我个人不推荐)这个选项会在INSERT语句中捆上一个LOCK TABLE和UNLOCK TABLE语句。这就防止在这些记录被再次导入数据库时其他用户对表进行的操作实例:LOCK TABLES `pwss` WRITE;
    /*!40000 ALTER TABLE `pwss` DISABLE KEYS */;
    INSERT INTO `pwss` VALUES (1,'weiwei','I love this girl');
    /*!40000 ALTER TABLE `pwss` ENABLE KEYS */;
    UNLOCK TABLES;
      
      -c or - complete_insert这个选项使得mysqldump命令给每一个产生INSERT语句加上列(field)的名字。当把数据导出导另外一个数据库时这个选项很有用。实例:INSERT INTO `pwss` (`id`, `username`, `description`) VALUES (1,'weiwei','I love this girl');  --delayed-insert
    在INSERT命令中加入DELAY选项  -F or -flush-logs
    在执行导出之前将会刷新MySQL服务器的log.  -f or -force
    即使有错误发生,仍然继续导出  -l or --lock-tables
    导出表的时候服务器将会给表加锁。(同上:--add-locks)  -t or --no-create- info这个选项使的mysqldump命令不创建CREATE TABLE语句,这个选项在您只需要数据而不需要DDL(数据库定义语句)时很方便。
      
      -d or --no-data
    这个选项使的mysqldump命令不创建INSERT语句。在您只需要DDL语句时,可以使用这个选项。  --opt
    此选项将打开所有会提高文件导出速度和创造一个可以更快导入的文件的选项。(个人推荐。如果没有使用--opt,MYSQLDUMP就会把整个结果集装载到内存中,然后导出。如果数据非常大就会导致导出失败。这个开关在默认情况下是启用的,如果不想启用它:--skip-opt来关闭它。)  -q or -quick
    这个选项使得MySQL不会把整个导出的内容读入内存再执行导出,而是在读到的时候就写入导文件中。这个和上面的开关一个意思。  --tab = path
    这个选项将会创建两个文件,一个文件包含DDL语句或者表创建语句,另一个文件包含数据。DDL文件被命名为tableName.sql,数据文件被命名为tableName.txt.路径名是存放这两个文件的目录。目录必须已经存在,并且命令的使用者有对文件的特权。(tableName.txt的结果相当于用select * from tablename into outfile的生成数据)
      
       --allow-keywords
    允许创建是关键词的列名字。这由表名前缀于每个列名做到。
        -C, --compress  
    如果客户和服务器均支持压缩,压
    缩两者间所有的信息。   -e, --extended-insert  使用全新多行INSERT语法。(给出更紧缩并且更快的插入语句)     -#, --debug[=option_string]  
    跟踪程序的使用(为了调试)。   --help  
    显示一条帮助消息并且退出。
     
       --fields-terminated-by=...  
       
       --fields-enclosed-by=...  
       
       --fields-optionally-enclosed-by=...  
       
       --fields-escaped-by=...  
       
       --fields-terminated-by=...  
    这些选择与-T选择一起使用,并且有相应的LOAD DATA INFILE子句相同的含义。  -pyour_pass, --password[=your_pass]  
    与服务器连接时使用的口令。如果你不指定“=your_pass”部分,mysqldump需要来自终端的口令。
     
       -P port_num, --port=port_num  
    与一台主机连接时使用的TCP/IP端口号。(任何系统通用)   -S /path/to/socket, --socket=/path/to/socket  
    与localhost连接时(它是缺省主机)使用的套接字文件。 (用于linux系统) 
     
       -u user_name, --user=userName  
    与服务器连接时,MySQL使用的用户名。 (LINUX系统缺省的who am i 的结果)    -O var=option, --set-variable var=option设置一个变量的值。可能的变量被列在下面。  
       -v, --verbose  
    冗长模式。打印出程序所做的更多的信息。(也就是详细信息)-B 开关可以生成CREATE DATABASE语句:C:\>mysqldump -udump_user -pdump_user -B woshitTest --add-drop-table -c> c:\\1.txt--tables这个很有用的一个开关。用于跳过--databases或者-B开关。该开关后面的所有名字均被认为是表名。实例:C:\>mysqldump -udump_user -pdump_user -B woshitTest --tables pwss --add-drop-table -c -R
     >> c:\\1.txt
    -R如果要导出存储过程,加 -R开关即可。实例:C:\>mysqldump -udump_user -pdump_user woshitTest pwss --add-drop-table -c --tab="c:\\" -
    v
    -- Connecting to localhost...
    -- Retrieving table structure for table pwss...
    -- Sending SELECT query...
    -- Disconnecting from localhost...
       -V, --version  
    打印版本信息并且退出。这里只谈了备份,不过恢复是最最主要的:mysql -udump_user -pdump_user woshittest< 1.txt
      

  7.   

     man mysqldump          Enclose the INSERT statements for each dumped table within SET AUTOCOMMIT=0 and COMMIT statements.       Â·  --no-create-db, -n          This option suppresses the CREATE DATABASE statements that are otherwise included in the output if the --databases or --all-databases option is given.       Â·  --no-create-info, -t          Do not write CREATE TABLE statements that re-create each dumped table.       Â·  --no-data, -d          Do not write any row information for the table. This is very useful if you want to dump only the CREATE TABLE statement for the table.

           Â·  --opt----------------------清注意下面的英文          This option is shorthand; it is the same as specifying --add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charset. It
              should give you a fast dump operation and produce a dump file that can be reloaded into a MySQL server quickly.          The --opt option is enabled by default. To disable the options that it enables, use --skip-opt. To disable only certain of the options enabled by --opt, use their --skip forms;
              for example, --skip-add-drop-table or --skip-quick.       Â·  --order-by-primary          Sorts each table’s rows by its primary key, or its first unique index, if such an index exists. This is useful when dumping a MyISAM table to be loaded into an InnoDB table,
              but will make the dump itself take considerably longer.       Â·  --password[=password], -p[password]          The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password
              value following the --password or -p option on the command line, you are prompted for one.          Specifying a password on the command line should be considered insecure. See Section 7.6, â€œKeeping Your Password Secure†      Â·  --port=port_num, -P port_num          The TCP/IP port number to use for the connection.       Â·  --protocol={TCP|SOCKET|PIPE|MEMORY}          The connection protocol to use.       Â·  --quick, -q          This option is useful for dumping large tables. It forces mysqldump to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and
              buffering it in memory before writing it out.       Â·  --quote-names, -Q          Quote database, table, and column names within â€˜â€˜â€™ characters. If the ANSI_QUOTES SQL mode is enabled, names are quoted within â€˜"’ characters. This option is enabled by
              default. It can be disabled with --skip-quote-names, but this option should be given after any option such as --compatible that may enable --quote-names.       Â·  --result-file=file, -r file          Direct output to a given file. This option should be used on Windows to prevent newline â€˜\n’ characters from being converted to â€˜\r\n’ carriage return/newline sequences.       Â·  --routines, -R          Dump stored routines (functions and procedures) from the dumped databases. The output generated by using --routines contains CREATE PROCEDURE and CREATE FUNCTION statements to
              re-create the routines. However, these statements do not include attributes such as the routine creation and modification timestamps. This means that when the routines are
    :
     This option is shorthand;--------------英文理解能力清楼上相信我
    这个歧义是翻译造成
    不是2个人的问题