MySQL命令详解:mysqlimport

语法:mysqlimport [options] 数据库名字  textfile1 [textfile2...]
示例:mysqlimport -uroot -p2143 test /tmp/city.txt
如果需要导入sql文件,可以使用mysql中的source 指令 :  source  /root/tb_book.sql   (进入Mysql)


MySQLimport位于MySQL/bin目录中,是MySQL的一个载入(或者说导入)数据的一个非常有效的命令行工具。 使用mysqlimport -?命令,可以查看mysqlimport的具体参数及详细说明。下表是一些常见的选项:

-C, --compress Use compression in server/client protocol. 压缩在客户端和服务器之间发送的所有信息(如果二者均支持压缩)
-d, --delete First delete all rows from table. 新数据导入数据表中之前删除数据数据表中的所有信息
--fields-terminated-by=name Fields in the textfile are terminated by … 指定数据之间的分隔符。默认的分隔符是跳格符(Tab)
--fields-enclosed-by=name Fields in the importfile are enclosed by ... 指定文本文件中数据的记录是以什么括起的, 很多情况下数据以双引号括起。 默认的情况下数据是没有被字符括起的
--fields-optionally-enclosed-by=name Fields in the i.file are opt. enclosed by … 字段包括符,只用在CHAR和VERCHAR字段上
--fields-escaped-by=name Fields in the i.file are escaped by ... 转义字符
-f, --force Continue even if we get an sql-error. 不管是否遇到错误,MySQLimport将强制继续插入数据
-?, --help Displays this help and exits. 显示帮助消息并退出
-h, --host=name Connect to host. 将数据导入给定主机上的MySQL服务器。默认主机是localhost
-i, --ignore If duplicate unique key was found, keep old row. 跳过或者忽略那些有相同唯一关键字的行, 导入文件中的数据将被忽略
--ignore-lines=# Ignore first n lines of data infile. 忽视数据文件的前n行
--lines-terminated-by=name Lines in the i.file are terminated by ... 行记录分隔符。 默认的情况下MySQLimport以newline为行分隔符
-L, --local Read all files through the client. 从本地客户端读入输入文件
-l, --lock-tables Lock all tables for write (this disables threads). 数据被插入之前锁住表,防止在更新数据库时,用户的查询和更新受到影响
--low-priority Use LOW_PRIORITY when updating the table. 低优先级
-p, --password[=name] Password to use when connecting to server. If password is not given it's asked from the tty. 提示输入密码
-W, --pipe Use named pipes to connect to server. 使用命名管道连接服务器
-P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306). 用于连接的TCP/IP端口号
--protocol=name The protocol of connection (tcp,socket,pipe,memory). 连接使用的协议
-r, --replace If duplicate unique key was found, replace old row. 与-i选项的作用相反;此选项将替代表中有相同唯一关键字的记录
--shared-memory-base-name=name Base name of shared memory. 共享内存连接名。该选项只用于Windows
-s, --silent Be more silent. 沉默模式。只有出现错误时才输出
-S, --socket=name Socket file to use for connection. 当连接localhost时使用的套接字文件(为默认主机)
--use-threads=# Load files in parallel. The argument is the number of threads to use for loading data. 并行多线程导入个数
-u, --user=name User for login if not current user. 连接服务器时MySQL使用的用户名
-v, --verbose Print info about the various stages. 冗长模式。打印出程序操作的详细信息
-V, --version Output version information and exit. 显示版本(version)


 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值