如果您想把EXCEL的数据或者CSV格式的数据导入到MySQL中,MySQL的CSV引擎再适合不过了。
MySQL的CSV引擎在5.0后开始提供,不过不支持WINDOWS,到了5.1才支持。
今天我测试的版本号是5.0.45
一、注意几点:
1、没有索引,跟MySQL5的数据字典库一样。
2、可以直接用任何文本编辑器来编辑数据文件。
3、非英文编码问题。
我的字符终端和表都是UTF-8的,所以要把上传的CSV文件保存为UTF-8的编码。
4、编码转化工具,我这边在WINDOWS下用EDITPLUS来转化,在LINUX下可以用ICONV命令行工具来转化编码。
二、示例数据文件。
"1","Designed for 99.999% Availability","MySQL Cluster provides a fault tolerant architecture that ensures your organization's mission critical applications achieve 99.999% availability. This means less than 5 minutes downtime per year, including scheduled maintenance time. MySQL Cluster implements automatic node recoverability to ensure an application automatically fails over to another database node that contains a consistent data set, if one or more database nodes fail. Should all nodes fail due to hardware faults for example, MySQL Cluster ensures an entire system can be safely recovered in a consistent state by using a combination of checkpoints and log execution. Furthermore, MySQL Cluster ensures systems are available and consistent across geographies by enabling entire clusters to be replicated across regions."
"2","High Performance Only a Main Memory Database Can Deliver","MySQL Cluster provides the response time and throughput to meet the most demanding high volume enterprise applications. MySQL Cluster achieves its performance advantage by being a main memory clustered database solution, which keeps all data in memory and limits IO bottlenecks by asynchronously writing transaction logs to disk. MySQL Cluster also enables servers to share processing within a cluster, taking full advantage of all hardware. Typical response times for MySQL Cluster are in the range of a few milliseconds and MySQL Cluster has been proven to handle tens of thousands of distributed transactions per second that are also replicated across database nodes."
"3","Extremely Fast Automatic Failover","MySQL delivers extremely fast failover time with sub-second response so your applications can recover quickly in the event of application, network or hardware failure. MySQL Cluster uses synchronous replication to propagate transaction information to all the appropriate database nodes so applications can automatically fail over to another node extremely quickly. This eliminates the time consuming operation of recreating and replaying log files required by 'Shared-Disk' architectures to fail over successfully. Plus, MySQL Cluster database nodes are able to automatically restart, recover, and dynamically reconfigure themselves in case of failures without having to program advanced features into the application."
"4","Flexible Distributed Architecture with No Single Point of Failure","The parallel server architecture combines database nodes, management server nodes, and application nodes that can be distributed across computers and geographies to ensure there is no single point of failure. Any node can be stopped or started without stopping the applications that use the database. And MySQL Cluster is highly configurable so you can implement the appropriate level of performance, scalability and fault tolerance to match your application requirements."
"5","Significantly Reduce Costly Downtime","MySQL Cluster not only lowers up-front license costs with affordable commercial licensing under a dual licensing mechanism, but it also significantly reduces system downtime - the number one contributor to the Total Cost of Ownership (TCO) of database software. Furthermore, a highly portable standards-based environment allows you to cost-effectively distribute your applications using commodity hardware and open source software infrastructure."
"6","Lower Maintenance Costs","MySQL Cluster is designed to be largely self-governing so very few system parameters actually need fine-tuning, further reducing the risk of costly errors. As a result, there are typically fewer conflicts with other software and hardware, and less need for manual intervention. This also means that MySQL Cluster will have a much lower maintenance costs, with less fine tuning required by Database Administrators."
"7","Easy-to-use Administration","MySQL Cluster includes easy to use and powerful tools for administering your clustered environment. Command line tools enable you to monitor database nodes, control access to applications, and create and restore backups."
"8","Services and Support","MySQL provides extensive consulting, training and technical support services to ensure the success of your next mission-critical database application project. MySQL has a proven track record gained through millions of successful customer deployments that can lower your risk and maximize return on investment."
"9","MySQL CLUSTER","以上是集群的特性概括"
"10","月亮他爸","我博客地址:[url]http://yueliangdao0608.cublog.cn[/url]"
"11","最要注意的一点","最后的一行必须有个空格!如果是中文,好奇怪!"

三、直接COPY数据文件到MySQL数据库目录下。
1、用EDITPLUS转码,然后进入MySQL命令行。
mysql> \C gbk
Charset changed
mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)
mysql> select sql_calc_found_rows * from ytt order by id desc limit 2\G
*************************** 1. row ***************************
     id: 11
  title: 最要注意的一点
summary: 最后的一行必须有个空格!如果是中文,好奇怪!"
*************************** 2. row ***************************
     id: 10
  title: 月亮他爸
summary: 我博客地址:[url]http://yueliangdao0608.cublog.cn[/url]"
2 rows in set (0.00 sec)

mysql> select found_rows();
+--------------+
| found_rows() |
+--------------+
|           11 |
+--------------+
1 row in set (0.00 sec)
2、用ICONV转码
现在可以直接用EXCEL来编辑数据文件,不过可惜的是EXCEL的编码是CP936的,所以传上去后要用ICONV来转码。

[root@localhost t_girl]# iconv -f CP936 -t UTF-8 ytt.CSV -o ytt.new
[root@localhost t_girl]# chown mysql:mysql ytt.new
[root@localhost t_girl]# cp -uf ytt.new ytt.CSV
[root@localhost t_girl]# ls -sihl
total 56K
13797305 8.0K -rw-rw---- 1 mysql mysql   61 Apr 30 15:19 db.opt
30539777 8.0K -rw-rw---- 1 mysql mysql  383 Jun 19 09:54 show_user.frm
13797308  12K -rw-r--r-- 1 mysql mysql 4.5K Aug  9 14:59 ytt.CSV
13797306  16K -rw-rw---- 1 mysql mysql 8.5K Aug  8 17:39 ytt.frm
13797307  12K -rw-r--r-- 1 mysql mysql 4.5K Aug  9 14:57 ytt.new
[root@localhost t_girl]# sed -i 's/^/"/g' ytt.CSV
[root@localhost t_girl]# sed -i 's/,/","/g' ytt.CSV
[root@localhost t_girl]# sed -i 's/$/"/g' ytt.CSV

用SED替换是为了用双引号来分割各个字段。

转载于:https://blog.51cto.com/yueliangdao0608/92045

MySQL的CSV引擎应用实例解析相关推荐

  1. MySQL常用存储引擎之CSV

    首先我们来看CSV这种存储引擎,CSV存储引擎呢,可以讲CSV文件,作为MYSQL的表来处理,这种存储引擎的存储格式呢,就是普通的CSV文件,CSV存储引擎的数据存储方式非常的有特点,如果我们把数据存 ...

  2. mysql csv 表头_Mysql实例mysql 导出CSV文件 并带表头的方法

    <Mysql实例mysql 导出CSV文件 并带表头的方法>要点: 本文介绍了Mysql实例mysql 导出CSV文件 并带表头的方法,希望对您有用.如果有疑问,可以联系我们. 参考官方文 ...

  3. 实例解析MySQL性能瓶颈排查定位

    优化系列 | 实例解析MySQL性能瓶颈排查定位 原文地址: http://imysql.com/2016/01/13/mysql-optimization-case-howto-find-perfo ...

  4. mysql各存储引擎的作用:Archive、Blackhole、CSV、Memory、Federated、Merge、NDB

    文章目录 1 Archive:用于数据存档 2 Blackhole:丢弃写操作,读操作会返回空内容 3 CSV:存储数据时,以逗号分隔各个数据项 4 Memory:置于内存的表 4.1 概述 4.2 ...

  5. MySQL的存储引擎InnoDB选择了B+ 树

    我们知道数据的存储和检索是两个很重要的功能,当我们的数据量大了,怎么能快速的检索数据呢,答案是使用索引,可索引具体的技术实现有很多,选择哪一种呢,我就以mysql为例记录下它为什么选择了B+树作为索引 ...

  6. unicode表_Python数据库操作 Mysql数据库表引擎与字符集#学习猿地

    # Mysql数据库表引擎与字符集 ![](./imgs/752951346A5F4E7EBDE362FA97107707.png) ### 1.服务器处理客户端请求 其实不论客户端进程和服务器进程是 ...

  7. Mysql数据库存储引擎--转

    原文地址:http://pangge.blog.51cto.com/6013757/1303893 简单介绍 存储引擎就是指表的类型.数据库的存储引擎决定了表在计算机中的存储方式.存储引擎的概念是My ...

  8. mysql 设计两个主键都不可重复_18个MySQL面试题剖析(答案解析),听说身为程序员的你还没掌握...

    1.数据库三范式是什么? 第一范式(1NF):字段具有原子性,不可再分.(所有关系型数据库系统都满足第一范式数据库表中的字段都是单一属性的,不可再分) 第二范式(2NF)是在第一范式(1NF)的基础上 ...

  9. 7.Mysql数据库表引擎与字符集

    7.Mysql数据库表引擎与字符集 1.服务器处理客户端请求 其实不论客户端进程和服务器进程是采用哪种方式进行通信,最后实现的效果都是:客户端进程向服务器进程发送 一段文本(MySQL语句),服务器进 ...

最新文章

  1. 201521123016《Java程序设计》第12周学习总结
  2. 国内唯一ACL最佳论文得主冯洋:冲击最佳论文需要知道的事情
  3. 返回浏览器或div 顶部
  4. ARP***原理与解决方法《一》
  5. 算术编码例题详解_百分数与百分点区别详解
  6. c#操作mysql 执行语句_c# 数据库编程(通过SqlCommand 执行DML语句)
  7. 【知识小课堂】4 之 索引
  8. 今年大学毕业照画风太清奇.....我忍不住笑出了声!
  9. windows 替换字体
  10. matlab方程组函数画图,MATLAB学习1 之画图函数
  11. 围棋棋盘有多少正方形 19*19
  12. 商业银行2022年12月升级UKEY证书后故障
  13. Keras 简介与优势
  14. CocosCreator接入穿山甲SDK(IOS)--激励视屏
  15. long 型应该加上 l或者L
  16. 记一次简单高效的吸血鬼算法
  17. Discriminative Feature Learning for Unsupervised Video Summarization(论文翻译)
  18. SOS:硬盘数据丢失怎么办?
  19. 省钱!程序员福利!!全国多地一分钱乘公交优惠活动来了!持续到5月底
  20. 爆改YOLOV7的detect.py制作成API接口供其他python程序调用(超低延时)

热门文章

  1. Android开发环境搭建Eclipse+JDK+ADT+AVD(系列一)
  2. 诗与远方:无题(二十四)
  3. 诗与远方:无题(十五)
  4. Python学习笔记之列表(一)
  5. RESTful测试工具RESTClient
  6. 微软DNS服务器默认,DNS 服务器成为一座岛 - Windows Server | Microsoft Docs
  7. 实现option上下移动_JS实现Select的option上下移动的方法
  8. c++ class struct同名_如何把C++的源代码改写成C代码?而C改C++只需一步!
  9. ASP.NET Core 使用MySQL(Database First)
  10. ajax请求头cookies中传递sid,跨域请求单点登录,登录成功,但是在controller中获取的cookie与浏览器中不一致,请大神指点一二。^_^...