Creating a MySQL dump in CSV format
来源:互联网 发布:aix mount linux nfs 编辑:程序博客网 时间:2024/05/21 17:11
Mostly, a dump of a db is wanted in SQL. In case of emergency import file. But some people do not comprehend SQL or their SQL doesn’t like your SQL and everything goes down the drain. So there is the CSV or Comma-separated values file. As the name says, it separates the values by commas (and more if needed). Since it’s so dead simple, you will get a lot of different tools and program languages that will make life easy for you to re-import or just search in it. Microsoft Excel and Openoffice Calc both can handle the format as well, so for a quick look, this will do very nicely.
But there is no simple –csv switch in mysqldump, your weapon of choice for these tasks. So here the command that will allow you to do what you are after:
mysqldump -p -u USER -T DIRECTORY --fields-enclosed-by=/" --fields-terminated-by=, DATABASE
So this is the short version, and here what it all means:
- -p : Asks for a password, as most users have one. If you don’t specify this on a database with a user/password, it will error
- -u USER : Replace USER with your actual username to connect to the database.
- -T DIRECTORY : This creates a tab delimited file. Not what we wanted but it’s the base we need.
- –fields-enclosed-by=/” : Will add ” characters around the fields. This will allow CSV implementations to find everything that fits together. You will need that backslash or it wont run.
- –fields-terminated-by=, : The so much sought after comma. This replaces the tab and puts a comma in its place, which, you guessed it, creates the CSV file.
- DATABASE : Well you know, the thing this is all about…
To actually be able to do it though, you will need the FILE privilege on this database. Armed with this, you should be able to do your CSV exports easy now.
- Creating a MySQL dump in CSV format
- Creating a Simple Web Application in NetBeans Using MySQL(1)
- Creating a Plug-In Framework
- Creating a Plug-In Framework
- Creating a User in a Domain and Creating Organizational Units
- Creating a Simple Win32 Service in C++
- Creating a Ruby Weblog in 10 Minutes
- Creating a immovable windows' form in c#
- Creating a Simple Win32 Service in C++
- Creating a File Manager in Adobe Air
- Creating a Base Window Class in WPF
- 2 Creating a Form in JavaFX
- Creating a legal filename in JavaScript
- Creating a Static Library in iOS Tutorial
- Creating a Static Library in iOS Tutorial
- Creating a Static Library in iOS Tutorial
- Android: creating two columns in a linearlayout
- Creating a Static Library in iOS Tutorial
- 这里
- vs2005设计界面出乱码的问题
- the greeter application appears to be crashing. attempting to use a different one...
- 你是否清楚,什么是真正的八拜之交?
- SecureCRT scripting
- Creating a MySQL dump in CSV format
- 无聊:正确的理解this 和 super
- datagridview动态锁定一列不允许用户修改其宽度
- 我在unpack 中写的一些技术文章集合,这些是对一些软件的注册过程进行分析的(比较简单)
- 关于泛型和重载的小问题
- 工作流WF4 关于参数
- 女儿与数独(女儿2岁+1个月)
- 常用的两种线程传参方式
- 工博会随想